[RESOLVED] Listbox question
i have this code with my listbox
Quote:
Private Sub Command1_Click()
If List1.ListIndex = -1 Then Exit Sub
Text1.Text = "press 2945#*3101#"
If List1.ListIndex = 0 Then Exit Sub
Text1.Text = "press 2945#*7101#"
If List1.ListIndex = 1 Then Exit Sub
Text1.Text = "press 2945#*7101#"
If List1.ListIndex = 2 Then Exit Sub
Text1.Text = "press 2945#*2601#"
If List1.ListIndex = 3 Then Exit Sub
Text1.Text = "press 2945#*9701#"
If List1.ListIndex = 4 Then Exit Sub
Text1.Text = "press 2945#*1201#"
If List1.ListIndex = 5 Then Exit Sub
Text1.Text = "press 2945#*1201#"
If List1.ListIndex = 6 Then Exit Sub
Text1.Text = "press 2945#*3311#"
If List1.ListIndex = 7 Then Exit Sub
Text1.Text = "press 2945#*7101#"
If List1.ListIndex = 8 Then Exit Sub
Text1.Text = "press 2945#*7101#"
End Sub
Quote:
Private Sub Form_Load()
With List1
.AddItem "LG C3100"
.AddItem "LG C3380"
.AddItem "LG F2300"
.AddItem "LG KE260"
.AddItem "LG KE970"
.AddItem "LG KG120"
End With
End Sub
the code is working perfect, but its badly coded because i have 50pcs of LG MODELS so the code If List1.ListIndex = X Then Exit Sub
Text1.Text = "press bla bla" is very long,
is there any way to make this short?
sorry for being a noob im really a beginner