Assign Index to Combobox

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 & ” = ” & id(ComboBox1.SelectedIndex))

End Sub

Explore posts in the same categories: Programming VB

Tags: , ,

You can comment below, or link to this permanent URL from your own site.

Comment: