English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Urgent.. Anyone who master in visual basic pls help.. i need to write a code that in a listbox got 3 item.. and if an item in a listbox is selected i need to do a funstion for different item selected.. who can help me. .

2007-01-17 16:09:46 · 4 answers · asked by Onikids 2 in Computers & Internet Programming & Design

4 answers

use the ListIndex property of the Listbox, and an If/Then/Else statement.

If lstBrands.ListIndex=0 then
msgbox "You like brand1"
ElseIf Lstbrands.listindex = 1 then
"You Love brand2"
ElseIf lstbrands.Listindex = 3 Then
msgbox "You don't like the other brands?"
End IF

2007-01-18 11:32:55 · answer #1 · answered by Richard H 7 · 0 0

If you want to continously check the Listbox contents then you should add a timer in the form.
Assuming timer has name = "timer1", interval = 100ms, enabled = true.
Then the following code should do the job.

Private Sub timer1_timer()
if List1.ListIndex = 0 then
Call Function1
elseif List1.ListIndex = 1 then
Call Function2
else
Call Function3
endif

End Sub

2007-01-17 18:26:59 · answer #2 · answered by aliasgherman 2 · 0 1

Use .ListIndex.

ListIndex returns the zero-based value.

' Example:
If List1.ListIndex = 0 Then
ThisFunction
ElseIf List1.ListIndex = 1 Then
ThatFunction
ElseIf List1.ListIndex = 2 Then
AnotherFunction
EndIf

2007-01-17 16:36:37 · answer #3 · answered by the DtTvB 3 · 0 0

once you're searching the thanks to create a label at runtime, you'll locate the syntax for turning out to be a label from scratch by technique of viewing the code seen Studio generates once you create a label interior the sorts clothier.

2016-10-15 09:39:22 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers