-1
我的組合框在選擇語句中不起作用,如果我在輸入值之後聲明本身有效。我認爲組合框本身可能存在問題,或者有人可能會看到我的代碼有問題嗎?Combobox不與選擇語句一起工作
Private Sub btnViewTimeTable_Click(sender As Object, e As EventArgs) Handles btnViewTimeTable.Click
If (cbDay.Text = "Monday" Or cbDay.Text = "Tuesday" Or cbDay.Text = "Wednesday" Or cbDay.Text = "Thursday" Or cbDay.Text = "Friday" Or cbDay.Text = "Saturday" Or cbDay.Text = "Sunday") Then
Dim SqlQuery As String = "SELECT Time, Activity, Equipment FROM TimeTable WHERE Day = 'cbDay.text'"
Dim da As OleDbDataAdapter = New OleDbDataAdapter(SqlQuery, conn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "Table")
Dim dt As DataTable = ds.Tables("Table")
With DGTimeTable
.AutoGenerateColumns = True
.DataSource = ds
.DataMember = "Table"
End With
With DGTimeTable
.Columns(0).Width = 108
.Columns(1).Width = 154
.Columns(2).Width = 278
Me.DGTimeTable.DefaultCellStyle.WrapMode = DataGridViewTriState.True
Me.DGTimeTable.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
End With
Else
MsgBox("Please Select a Day!")
End If
End Sub
謝謝史蒂夫! – HaydenKThomas