Hi,
Could anyone please tell me why both the following work?
TextBox.Text = "Something"
TextBox().Text = "Something"
Printable View
Hi,
Could anyone please tell me why both the following work?
TextBox.Text = "Something"
TextBox().Text = "Something"
Can't tell you why, but it's a little wierd. Makes it difficult to read. FWIW, C# won't let you do that.
I'd like to know too. But I'll take a guess and say that it's because TextBox1() is the same as referring to the only element in this zero dimensional array of textboxes.
I suppose if there were an array of textboxes, you'd be going
TextBox1(4).Text = "ABC"
Zero Dimension Array???? :eek:
I though that only existed in the brains of our politicians :D
Not to mention you can't do textbox(4).text in .net because control arrays where removed.
For all practical purposes, Control Arrays DO still exist in .NET. You just don't have a Control.Index property. They are not called that, but there is an Array of Controls available. E.G.Quote:
Originally Posted by Graff
VB Code:
Dim ctl As Control Dim TBArray(0) As TextBox Dim iCount As Integer For Each ctl In Me.Controls If TypeOf ctl Is TextBox Then TBArray(iCount) = CType(ctl, TextBox) iCount += 1 ReDim Preserve TBArray(iCount) End If Next
Or you can make up your own index using the Tag property but that is not so flexible.
You can have an array of anything in .net (pretty much). The framework doesn't give a damn if you want to declareQuote:
Originally Posted by Graff
dim tb() as textbox = new textbox(5) {}
that's perfectly valid. Control arrays in VB6 were weird things and not even proper arrays.
But they made life easy.
you need to use this
textbox1.text = "somthing"
Quote:
Originally Posted by Graff
Hi,
Using an array of controls in VB.NET is just as easy as using a Control Array in VB6.
Not quite