Calculation

gomindi

Freshman
Joined
Aug 28, 2002
Messages
25
Location
UT
Here is the code that I am using (Thanks to Divil) to create a textbox on the fly:

Dim a As New TextBox()
a.Text = items(0)
a.Location = New Point(20, 75)
Controls.Add(a)

Now I would like to know how to create a variable that will calculate my next location of my text box.

Any ideas? Thanks! Mindi
 
You should also specify the size, with:
a.Size = New Size(64, 24) '64x24 pixels

The new location depends on what you want. Normally you'll use an offset from the previous textbox. You might have something like:
Code:
Dim lastY As Int32 = 0

'looping here
    Dim a As New TextBox()
    a.Text = items(0)
    a.Size = New Size(64, 24)
    a.Location = New Point(20, lastY)
    Controls.Add(a)

    '4 represents 4 pixels between each textbox
    lastY = lastY + a.Height + 4 
    'or use the following:
    'lastY = a.Top + a.Height + 4

'loop til here

How you're doing your looping and where you're creating your textbox will determine how/where you store that last Y value.

-Nerseus
 
Back
Top