VB6 to VB.NET Indexing Help

  • Thread starter Thread starter David S. Zuza
  • Start date Start date
D

David S. Zuza

Hey,

I am new to .NET and I would like to index a button control on my form
just like I used to be able to in VB6. In VB6 all I had to do was create one
control and new to something like

cmdButton()

and then I could copy it in the design window and refer to anyone of the
buttons by refencing its index like

cmdButton(43).Backcolor = vbRed

how could I accomplish the same thing in .NET

I was considering creating each button at runtime but it would be better if
I could design and place each button considering that there is over 80
different buttons and their placement is crucial.

thanks for the help in advance
 
index is not longer to used in vb.net
use array
dim tb() as textbox
u can copy and paste it

Dim textboxGrid(8, 8) As TextBox
Private Sub makeGrid()
Dim txtBox As TextBox
Dim xPos, yPos As Integer

yPos = 45
For row As Integer = 0 To 8
xPos = 20
For column As Integer = 0 To 8
txtBox = New TextBox
txtBox.Parent = Me
txtBox.Location = New Point(xPos, yPos)
txtBox.BorderStyle = BorderStyle.FixedSingle
txtBox.Multiline = True
txtBox.Size = New Size(50, 50)
txtBox.Text = "0"
txtBox.TextAlign = HorizontalAlignment.Center
textboxGrid(row, column) = txtBox
Me.Controls.Add(txtBox)
xPos += 50
Next
yPos += 50
Next
End Sub
the u will have to do "for each" and "typeof"
regards
 
Thanks but I did not want to create them at runtime,

I need to edit them at design time but update them during runtime. Also,
they will be located at specific locations on the screen (not in a grid) and
they will differ in size.

There has to be a better way

David Zuza
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top