Public Sub connectData() Handles MyBase.Load
Dim S As String
If conn.State = ConnectionState.Open Then conn.Close()
S = "Provider=Microsoft.Jet.OLEDB.4.0;"
S = S + "Data Source=C:\data.mdb;"
S += "User Id=admin;Password=;"
conn.ConnectionString = S
conn.Open()
End Sub
Private Sub btnSearchTables_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Dim dr As OleDbDataReader
Dim Esan As String = tetNotes.Text
Dim s As String = "Select * From Dic Where Esan ='" & Esan & "' "
dr = ExecuteReader(s)
If dr.HasRows Then
dr.Read()
txtshow.Text = dr.Item("Thai").ToString
Else
MessageBox.Show("ไม่พบคำศัพท์ที่ท่านต้องการค้นหา")
End If
End Sub
Private Sub ComboBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
AutoCompleteCombo(CType(sender, ComboBox), e)
End Sub
Public Shared Sub AutoCompleteCombo(ByVal cbo As ComboBox, ByVal e As KeyEventArgs)
Dim sTypedText As String
Dim iFoundIndex As Int32
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String
'Allow select keys without Autocompleting
Select Case e.KeyCode
Case Keys.Back
Exit Select
Case Keys.Left
Exit Select
Case Keys.Right
Exit Select
Case Keys.Tab
Exit Select
Case Keys.Up
Exit Select
Case Keys.Delete
Exit Select
Case Keys.Down
Exit Select
End Select
'Get the Typed Text and Find it in the list
sTypedText = cbo.Text
iFoundIndex = cbo.FindString(sTypedText)
'If we found the Typed Text in the list then Autocomplete
If iFoundIndex >= 0 Then
'Get the Item from the list (Return Type depends if Datasource was bound or List Created)
oFoundItem = cbo.Items(iFoundIndex)
'Use the ListControl.GetItemText to resolve the Name in case the Combo was Data bound
sFoundText = cbo.GetItemText(oFoundItem)
'Append then found text to the typed text to preserve case
sAppendText = sFoundText.Substring(sTypedText.Length)
cbo.Text = sTypedText.ToString() + sAppendText.ToString()
'Select the Appended Text
cbo.SelectionStart = sTypedText.Length
cbo.SelectionLength = sAppendText.Length
End If
End Sub
Dim dr As OleDbDataReader
Dim Esan As String = tetNotes.Text
Dim s As String = "Select * From Dic Where Esan ='" & Esan & "' "
dr = ExecuteReader(s)
If dr.HasRows Then
dr.Read()
txtshow.Text = dr.Item("Thai").ToString
Else
MessageBox.Show("ไม่พบคำศัพท์ที่ท่านต้องการค้นหา")
End If