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,

Recommended Answers

All 4 Replies

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


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
MsgBox  Mystr


veena..., great.

Thanks JX_Man :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.