0

Hi everyone, I wonder if somebody can help me with the following please.

I have a number of textBoxes on a page that I want to check with a for next statement.

e.g, the boxes are called (imaginatively), txtBox1, txtBox2, txtBox3...

I would like to build a statement where I can get the values from the for..next..loop

so it would look something like this.

for n=1 to 3

This is the statement I would like to know how to construct.

txtBox(n).text so that it would read txtBox1.text

Something like the eval statement in Javascript.

next n

Cheers in advance,
Steve.

3
Contributors
4
Replies
6
Views
10 Years
Discussion Span
Last Post by QVeen72
0

Make all textbox as control array.
So, first draw one text box then copied it. vb 6 will give u a message to make textbox as control array or not. click yes to make it as control array.
After it you can make loop and get value from all text box.
Ex :

Dim i As Integer
For i = 0 To 2
    With List1
        .AddItem (Text1(i).Text)
    End With
Next i
0

Hi,

Try This :

Dim i As Integer
Dim Mystr As String
Dim ctl As TextBox
Mystr = ""
For i = 1 To 3
    Set ctl = Me.Controls("Text" & CStr(i))
    Mystr = Mystr & ctl.Text
Next
MsgBox  Mystr

Regards
Veena

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.