VB.Net
Moderator: Forum Moderators
-
- Throbbing Cupcake
- Posts: 10249
- Joined: February 17th, 2007, 23:05
- Location: The maleboge
-
- Morbo
- Posts: 19676
- Joined: December 10th, 2004, 21:53
- Contact:
-
- Throbbing Cupcake
- Posts: 10249
- Joined: February 17th, 2007, 23:05
- Location: The maleboge
I dont understand this methodor even more effeicentCode: Select all
Public ReadOnly Property lblName2 as Label Get Dim o as control = Me.FindControl("lblName2") If o Is Nothing then Return Nothing Return Ctype(o,Label) End Get End Property
The properties method is not recommended when you do not want to limit the number of labels.Code: Select all
Private _lblName2 as Label = Nothing Public ReadOnly Property lblName2 as Label Get If _lblName2 Is Nothing Then _lblName2 = Me.FindControl("lblName2") End If Return _lblName2 End Get End Property
And it keeps telling me FindControl isnt a member of my form
Oh and the other methoderror BC30456: 'FindControl' is not a member of 'Teams.Scr2'
Well it breaks on myControl.ID as it gives me this errorWhen you add a control, do something like this:
Code: Select all
Dim myControl As New Label myControl.ID="lblName2" Me.Controls.Add(MyControl)
error BC30456: 'ID' is not a member of 'System.Windows.Forms.Label'.
Appologies, use this instead:
Instead of FindControl, use instead
I loaded up VB to test these and they work. The ones posted previous were from the top of my head, and for a web application.
Ignore the readonly properties for now, they only serve to overcomplicate things
Code: Select all
Dim myControl As New Label
myControl.Name = "lblName2"
Me.Controls.Add(myControl)
Code: Select all
Me.Controls.Find("lblName2")
Ignore the readonly properties for now, they only serve to overcomplicate things
Hey Fear
I cant do that it wont let me
produces the errors
Are you using VB.Net 2005?
I cant do that it wont let me
Code: Select all
CType(Scr2.Controls.Find(lblName), Label).Text = txtTeamName(1).Text
&error BC30455: Argument not specified for parameter 'searchAllChildren' of 'Public Function Find(key As String, searchAllChildren As Boolean) As System.Windows.Forms.Control()'.
I can fix the first error by changing code toerror BC30311: Value of type '1-dimensional array of Teams.lblch' cannot be converted to 'String'.
Code: Select all
CType(Scr2.Controls.Find(lblName, true), Label).Text = txtTeamName(1).Text
Me.Controls.Find("lblName2", false)
I fail at cut and paste.
Note the lblName2 is a string.
Basically what you are doing is adding a control with the name "WhatEverYouWant" and then finding it by searching for "WhatEverYouWant"
This method allows you to have as many dynamic controls as you want, and all you have to do is refer to them by their name as a string. You don't need to track anything with arrays.
I fail at cut and paste.
Note the lblName2 is a string.
Basically what you are doing is adding a control with the name "WhatEverYouWant" and then finding it by searching for "WhatEverYouWant"
This method allows you to have as many dynamic controls as you want, and all you have to do is refer to them by their name as a string. You don't need to track anything with arrays.
Re: VB.Net
Make him learn Turbo Pascal, then some useful language like C++.Wiggy wrote:Anyone know anything to do with VB.Net? I have a mate who's looking for some help with a program he's trying to make.
Re: VB.Net
TP = SHIT I know I have used itBaliame wrote:
Make him learn Turbo Pascal, then some useful language like C++.
C#.Net is my current working out but as this is just a quick program I dobnt need anything as powerful as C#