I have following code to search combobox which I need to repeat in different forms and different comboboxes
I am using from key up event
Private Sub ComboBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
' Store the actual text that has been typed.
actual = Me.ComboBox1.Text
Me.TextBox1.Text = Me.ComboBox1.Text
' Find the first match for the typed value.
index = Me.ComboBox1.FindString(actual)
TextBox2.Text = Me.ComboBox1.FindString(actual)
' Get the text of the first match.
If (index > -1) Then
found = Me.ComboBox1.Items(index).ToString()
Me.TextBox2.Text = found
' Select this item from the list.
Me.ComboBox1.SelectedIndex = index
' Select the portion of the text that was automatically
' added so that additional typing will replace it.
Me.ComboBox1.SelectionStart = actual.Length
Me.ComboBox1.SelectionLength = found.Length
End If
end sub
I would like to repeat by passing my combobox name to a subroutine so i don't have to repeat this code each time
Is this possible?
I am using from key up event
Private Sub ComboBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
' Store the actual text that has been typed.
actual = Me.ComboBox1.Text
Me.TextBox1.Text = Me.ComboBox1.Text
' Find the first match for the typed value.
index = Me.ComboBox1.FindString(actual)
TextBox2.Text = Me.ComboBox1.FindString(actual)
' Get the text of the first match.
If (index > -1) Then
found = Me.ComboBox1.Items(index).ToString()
Me.TextBox2.Text = found
' Select this item from the list.
Me.ComboBox1.SelectedIndex = index
' Select the portion of the text that was automatically
' added so that additional typing will replace it.
Me.ComboBox1.SelectionStart = actual.Length
Me.ComboBox1.SelectionLength = found.Length
End If
end sub
I would like to repeat by passing my combobox name to a subroutine so i don't have to repeat this code each time
Is this possible?