List Box help

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 2
Reputation: PkTidus is an unknown quantity at this point 
Solved Threads: 0
PkTidus PkTidus is offline Offline
Newbie Poster

List Box help

 
0
  #1
Oct 3rd, 2008
Hello, I need to know how to "extract" information out of list box.

        Dim intLoop As Integer
        Dim blnStartG As Boolean
        Dim intCounter As Integer
        Dim strMedal As String

        Dim intcheck As Integer

        For intLoop = 0 To (lstResults.Items.Count = -1)
            blnStartG = False
            strMedal = lstResults.?????????
            blnStartG = strMedal.StartsWith("G")
            If blnStartG = True Then
                intCounter = intCounter + 1
            End If
            intcheck = intcheck + 1
        Next
        MessageBox.Show("Total amount of gold medals are: " & intCounter & " " & intcheck, "Amount", MessageBoxButtons.OK, MessageBoxIcon.Information)

What I am trying to do is count all the items that start with "G". I'm sure the method I'm trying to use is correct but I need to know how to get the name of the item from the List box to the varible "StrMedal".

Many thanks, Anthony

P.s I know know its a strange program, its for college
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: List Box help

 
0
  #2
Oct 3rd, 2008
Can you use a For Each statement with a list?

Dim word as String
For Each word in lstResults
strMedal = word
blnStartG = strMedal.StartsWith("G")

etc . . .
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2
Reputation: PkTidus is an unknown quantity at this point 
Solved Threads: 0
PkTidus PkTidus is offline Offline
Newbie Poster

Re: List Box help

 
0
  #3
Oct 3rd, 2008
The for statement won't work coz I won't know how many items will be in the list box.

What I need to know is what code do I need to pull out the name of the item in the list box.

So if I had in a list box..

Gold - Running
Silver - Swimming
Gold - 100 meter

it would pull out all the names from the list box that starts with "G" and processes the name. Sorry if it isn't very clear
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: List Box help

 
0
  #4
Oct 3rd, 2008
I'm not talking For statements - I'm talking For Each and Next . . .
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC