MyArmsFellOff MyArmsFellOff - 4 months ago 21 Question

Inputting Multiple Data into Text Boxes

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.

is entered by the user.

Dim noofcompetitors As Integer
Dim surname(noofcompetitors) As String
Dim firstname(noofcompetitors) As String

The user then inputs surname and firstname into text boxes a
amount of times. The data from the text boxes are inserted into the arrays on button click.

I'll try to explain what I've got. The user enters the integer variable into a text box, showing several new text boxes. From there, the user enters data into these text boxes (e.g. surname, firstname). These are saved into individual variable arrays at a button click. The text boxes are reset and the user enters data into the text boxes again. These are then saved into the array. This continues until the data is entered the integer variable number of times (e.g. 25 times). I'm not sure how I enter these into individual variable arrays, as the number of times they are entered changes


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
   Msgbox("Number of amount compititors succeeded") 'or whatever you want to do here
  End If
End Sub