listbox index

J

Jeff Ciaccio

Man the help in VB.NET is hard to use!!

Can somebody please tell me the syntax to find the index value a user has
chosen from a list of items in a listbox. Also, is there a way to use the
string value instead of the index number?

I'm trying to do something like...

if lstBox.items.index = 0 then
stuff...
end if

OR

if lstBox.items.index = "California" then
stuff...
end if
 
K

kimiraikkonen

Man the help in VB.NET is hard to use!!

Can somebody please tell me the syntax to find the index value a user has
chosen from a list of items in a listbox. Also, is there a way to use the
string value instead of the index number?

I'm trying to do something like...

if lstBox.items.index = 0 then
stuff...
end if

OR

if lstBox.items.index = "California" then
stuff...
end if

--
Jeff Ciaccio
Physics and AP Physics Teacher
Sprayberry High School; Marietta, GA
Blog:http://sprayberry.typepad.com/ciaccio

As i understood, you need to get "selected" index and item:

For index value you need "lstBox.SelectedItems" :

' -----------------------------------

f lstBox.SelectedIndex = 0 then
' stuff...
end if

' ---------------------------------


To get Selected Item you need "lstBox.SelectedItem" :

' --------------------------------

if lstBox.SelectedItem = "California" then
stuff...
end if

' -----------------------

Thanks,

Onur Güzel
 
K

kimiraikkonen

As i understood, you need to get "selected" index and item:

For index value you need "lstBox.SelectedItems" :

' -----------------------------------

f lstBox.SelectedIndex = 0 then
' stuff...
end if

' ---------------------------------

To get Selected Item you need "lstBox.SelectedItem" :

' --------------------------------

if lstBox.SelectedItem = "California" then
stuff...
end if

' -----------------------

Thanks,

Onur Güzel

Sorry correcting first line of my post:

For index value you need "lstBox.SelectedIndex" :

' -----------------------------------

f lstBox.SelectedIndex = 0 then
' stuff...
end if

' ........

Thanks,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top