I am trying to have a textbox set up where multple texboxes are used in teh layout of a table, each one as a seperate box in. (I havn't got the exact size figured out yet but for the sake of testing i've been usieng a layout of 2 rows by 6 coloms.)
I am trying to use an easy methiod in which I can add text into these box by uses variables. For example a layout of textboxes titled like this

    Wall1     Wall2    Wall3   Wall4   Wall5   Wall6 

Using this sort of code:

Dim box As Integer
    Dim wall As String
    Dim num As String
    Do While box < 6
        box = box + 1
        num = box
        wall = "Wall" + num
        wall.items.add("!") 
        Where the variable would become wall1, wall2, wall3 ect.

Recommended Answers

All 2 Replies

Side note: I can also use list boxes if its easier. I just want to know how i can get teh program to indentify a text/list box by using a variable instead of the box name

You can reference a control dynamically by name like

num = 4
dim tbx as TextBox = Me.Controls("TextBox" & num)

Then you can reference the control through the variable. If you want to cycle through a series of TextBoxes just put it in a look like

For i As Int = 1 To 5
    dim tbx as TextBox = Me.Controls("TextBox" & i)
    tbx.Text = ....
Next
Be a part of the DaniWeb community

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