Code to Assign Index
************************************************************
Public Class Form13
Dim id(5) As Integer
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add(“Item 1″)
ComboBox1.Items.Add(“Item 2″)
ComboBox1.Items.Add(“Item 3″)
ComboBox1.Items.Add(“Item 4″)
ComboBox1.Items.Add(“Item 5″)
id(0) = 10
id(1) = 20
id(2) = 30
id(3) = 40
id(4) = 50
end sub
******************************************************
To test the index
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(ComboBox1.Text & ” = ” & [...]
Archive for the 'Programming VB' Category
Assign Index to Combobox
July 17, 2008Vb Keypress
July 17, 2008This keypress will work if you want the textbox to accept numeric data only
For VB.net
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.KeyChar = Chr(0)
End If
End Sub
For VB 5 & 6
on keypress event
Private Sub txtEndtNo_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 13 And KeyAscii <> 8 Then KeyAscii [...]