Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This might be confusing: wut if i wanted to create a series of 10 textboxes called 'textbox1', 'textbox2', etc in a for loop? is this possible? ex:

 

for i = 0 to 10

dim textboxX as new textbox()

next

 

i kno thats not the right way, but does anyone kno how to do replace the X with the # that i is currently?

  • *Experts*
Posted
Use an array.
Dim tb(9) As TextBox
Dim i As Integer

For i = 0 to 9
 tb(i) = New TextBox
 'set TextBox(i) properties
 Me.Controls.Add(tb(i))
Next i

  • *Experts*
Posted
As long as you defined them the same way I did, you could do that. You can also enumerate all TextBoxes on the form:
Dim tb As New TextBox

For Each tb In Me.Controls
 tb.BackColor = Color.Red
Next

Posted

this is a little more confusing: just as a test of my skills, im making a program that loads data from a file and sets that color to one of the 16 panels. I just saved the file with 'Color.Red' and different colors for 16 lines and im trying to set the properties of Panels1-16 each lineinput. heres wut i have so far:

 

Dim P As New Panel()

Dim C As String

FileOpen(1, "w.txt", OpenMode.Input)

For Each P In Me.Controls

C = LineInput(1)

If C = "Blue" Then

P.BackColor = Color.Blue

ElseIf C = "Red" Then

P.BackColor = Color.Red

ElseIf C = "Green" Then

P.BackColor = Color.Green

End If

Next

 

but u see, i want to be able to set each of the 16 lines uniquely instead of the 3 colors i have coded. like if i wanted to set the backcolor of panel1, i would set the first line in the file to 'Color.Brick'. i cant just say 'pb(i).backcolor = lineinput(1)'. how can i do this?

  • *Experts*
Posted

If they're from the KnownColor enum, you can use Color.FromKnownColor©

 

If the color you store isn't a known color (just some semi-random RGB values) you'll have to do it another way.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...