I have an integer variable and multiple text boxes. The user enters data into these text boxes and presses a button. The data in these text boxes is saved as variables. Then, the text boxes are reset and the process is repeated, before saving them as variables again. This is done a number of times, from 1 to the integer variable. How can I do this, so that I can put each variable from the text boxes into an array so they can be sorted and searched?
If you have any questions, please ask.
These are the variables.
Dim noofcompetitors As Integer
Dim surname(noofcompetitors) As String
Dim firstname(noofcompetitors) As String
I would suggest using generic lists instead and using an if statement to check if number of competitors added are more than they have asked for. I obviosuly didnt know what your button was called or the textboxes so i made up names for them you can replace. Is this what you sort of looking for?
'These are your global variables Dim noofcompetitors As Integer Dim surname As List(of string) Dim firstname As List(of string) Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click If (surname.count - 1) < noofcompititors Then surname.add(tbSurname.text) firstname.add(tbFirstname.text) Else Msgbox("Number of amount compititors succeeded") 'or whatever you want to do here End If End Sub