|
-
Apr 8th, 2003, 06:27 AM
#1
Thread Starter
Frenzied Member
Textbox array?
I've started using VB.net instead of VB6. I'm missing the possiblity of making textboxes as an array. In VB6 this is standard, but is it possible at all in VB.Net?
-
Apr 8th, 2003, 03:06 PM
#2
PowerPoster
There are no control arrays in .net like there was in VB6.
What is it your trying to do?
-
Apr 8th, 2003, 07:47 PM
#3
PowerPoster
to make a control array in .NET you create for example 3 textboxes named text1,text2,text3 respectively. Then in the text1 change event(Or any event) where it says Handles you append the extra textbox names and events.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged
I havnet figured out how to detect which textbox was used, but this fires the event for all 3 textboxes.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Apr 8th, 2003, 09:18 PM
#4
PowerPoster
I havnet figured out how to detect which textbox was used, but this fires the event for all 3 textboxes.
The way to figure out which one is to cast the sender object to a textbox, then refer to the senders name.
VB Code:
Dim myTextBox As TextBox
myTextBox = CType(sender, TextBox)
If myTextBox.Name = TextBox1 Then
' Do your processing for textbox 1.
End If
If myTextBox.Name = TextBox2 Then
' Do your processing for textbox 2.
End If
-
Apr 9th, 2003, 01:25 AM
#5
Thread Starter
Frenzied Member
I have a this sub:
Code:
Private Sub btnNulstil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNulstil.Click
txtKar1.Text = ""
txtKar2.Text = ""
txtKar3.Text = ""
txtKar4.Text = ""
txtKar5.Text = ""
End Sub
Imagine that I had 100 text boxes, I would'nt like to write the lines txtKarX.text ="" up to 100. How can I make this in a smart way?
-
Apr 9th, 2003, 11:15 PM
#6
PowerPoster
good question.. and i have no earthly idea why microsoft got rid of control arrays.
But i would think you would loop thru them using some sort of Object collection thingy.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|