homebrew311 Posted November 5, 2003 Posted November 5, 2003 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? Quote
*Experts* Volte Posted November 5, 2003 *Experts* Posted November 5, 2003 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 Quote
homebrew311 Posted November 6, 2003 Author Posted November 6, 2003 wut about editing the properties of existing ones? for i = 1 to 10 textbox(i).text = i next Quote
*Experts* Volte Posted November 6, 2003 *Experts* Posted November 6, 2003 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 Quote
homebrew311 Posted November 6, 2003 Author Posted November 6, 2003 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? Quote
*Experts* Nerseus Posted November 6, 2003 *Experts* Posted November 6, 2003 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 Quote "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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.