Count the number of textbox with equal value

July 14, 2011 at 21:15:23
Specs: N/A
Using Visual Studio 2010, Windows Apps (VB.Net 4)
1) 30 Textbox
2) Each Textbox will display either one value 0, 1, 2
3) 3 Textbox
TextboxA - Will display the number of textbox with value 0
TextboxB - Will display the number of textbox with value 1
TextboxC - Will display the number of textbox with value 2
4) Button Click will count and display the value in TextBoxA, TextBoxB, TextBoxC

Many thanks


See More: Count the number of textbox with equal value

Report •


#1
July 15, 2011 at 01:08:05
So you want us to do this for you?

Have you atleast attempted it, can we see your code?

1) Make a control array of the textbox's
2) loop through them and read the values, accordingly increment the variables that count the 0, 1 and 2

once you get to the end of the array, display the variables values in the three texbox's


Report •

#2
July 15, 2011 at 01:26:06
I am new to vb.net scripting. I have tried coding and this is my latest code.
I manage to get a looping up reading each textbox value but stuck with string to integer conversion. Here is my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim v0 As Integer = 0

Dim q As Integer = 0

Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim p As Integer
z = 1
p = 0

For x = 1 To 32
For y = 1 To 32
p = y + x - z
If Int32.Parse(Me.Controls("TextBox" & p).Text) = v0 Then
q = q + 1
MessageBox.Show(q)
Else
If p = 32 Then
Exit Sub
End If
End if
Next y
Next x
End Sub

Many thanks


Report •
Related Solutions


Ask Question