You are viewing our Forum Archives. To view or take place in current topics click here.
help with a code from vb 2008 (sintaxis)
Posted:
help with a code from vb 2008 (sintaxis)Posted:
Status: Offline
Joined: Apr 11, 201113Year Member
Posts: 4
Reputation Power: 0
i need a code of vb 2008 to find a number in a list box write in a textbox with a botton that says find number
note: im new in ttg please help
note: im new in ttg please help
#2. Posted:
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
Um please be more descriptive. Do you want it to be a random number? And how many numbers are in the ListBox?
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Apr 11, 201113Year Member
Posts: 4
Reputation Power: 0
There are 5 numbers in the list box and if the number is found,
will see a msgbox saying "the number is found" otherwise "the number cannot found" in another msgbox can you help me
will see a msgbox saying "the number is found" otherwise "the number cannot found" in another msgbox can you help me
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
Just put this code under button1 click (or whatever you named the button)
Tell me if this works (I used a converter because I don't know VB)
Tell me if this works (I used a converter because I don't know VB)
Dim theItems As Integer() = New Integer(listBox1.Items.Count) {}
For i As Integer = 0 To listBox1.Items.Count - 1
theItems(i) = Integer.Parse(listBox1.Items(i).ToString())
Next
For Each myInt As Integer In theItems
If myInt = Integer.Parse(textBox1.Text) Then
MessageBox.Show("The number is found.")
Return
End If
Next
MessageBox.Show("The number cannot be found.")
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.