Page 2 of 2

Posted: March 2nd, 2008, 16:54
by HereComesPete
You want to do what to berk? :shock:


That's sickening! :faint:

Posted: March 2nd, 2008, 16:55
by Dr. kitteny berk
HereComesPete wrote:You want to do what to berk? :shock:


That's sickening! :faint:

It's a natural reaction to how awesome I am.

Posted: March 2nd, 2008, 17:04
by HereComesPete
Awesomely sickening. Can you cyber with Hehulk through pm's please, you'll drive off the new fella. :P

Posted: March 2nd, 2008, 17:07
by sedontane
Posted in the hello forum

Posted: March 2nd, 2008, 21:03
by sedontane

Code: 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
or even more effeicent

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
The properties method is not recommended when you do not want to limit the number of labels.
I dont understand this method

And it keeps telling me FindControl isnt a member of my form
error BC30456: 'FindControl' is not a member of 'Teams.Scr2'
Oh and the other method
When you add a control, do something like this:

Code: Select all

Dim myControl As New Label
myControl.ID="lblName2"
Me.Controls.Add(MyControl)
Well it breaks on myControl.ID as it gives me this error
error BC30456: 'ID' is not a member of 'System.Windows.Forms.Label'.

Posted: March 2nd, 2008, 22:11
by Fear
Appologies, use this instead:

Code: Select all

        Dim myControl As New Label
        myControl.Name = "lblName2"
        Me.Controls.Add(myControl)
Instead of FindControl, use instead

Code: Select all

Me.Controls.Find("lblName2")
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

Posted: March 2nd, 2008, 22:32
by sedontane
Hey Fear

I cant do that it wont let me

Code: Select all

CType(Scr2.Controls.Find(lblName), Label).Text = txtTeamName(1).Text
produces the errors
error BC30455: Argument not specified for parameter 'searchAllChildren' of 'Public Function Find(key As String, searchAllChildren As Boolean) As System.Windows.Forms.Control()'.
&
error BC30311: Value of type '1-dimensional array of Teams.lblch' cannot be converted to 'String'.
I can fix the first error by changing code to

Code: Select all

CType(Scr2.Controls.Find(lblName, true), Label).Text = txtTeamName(1).Text
Are you using VB.Net 2005?

Posted: March 2nd, 2008, 23:27
by Fear
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.

Re: VB.Net

Posted: March 3rd, 2008, 10:03
by Baliame
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.
Make him learn Turbo Pascal, then some useful language like C++.

Re: VB.Net

Posted: March 3rd, 2008, 10:55
by sedontane
Baliame wrote:
Make him learn Turbo Pascal, then some useful language like C++.
TP = SHIT I know I have used it

C#.Net is my current working out but as this is just a quick program I dobnt need anything as powerful as C#