VB.Net

If you touch your software enough does it become hardware?

Moderator: Forum Moderators

HereComesPete
Throbbing Cupcake
Throbbing Cupcake
Posts: 10249
Joined: February 17th, 2007, 23:05
Location: The maleboge

Post by HereComesPete »

You want to do what to berk? :shock:


That's sickening! :faint:
Dr. kitteny berk
Morbo
Morbo
Posts: 19676
Joined: December 10th, 2004, 21:53
Contact:

Post 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.
HereComesPete
Throbbing Cupcake
Throbbing Cupcake
Posts: 10249
Joined: February 17th, 2007, 23:05
Location: The maleboge

Post by HereComesPete »

Awesomely sickening. Can you cyber with Hehulk through pm's please, you'll drive off the new fella. :P
sedontane
Mouse
Mouse
Posts: 10
Joined: March 2nd, 2008, 14:24
Contact:

Post by sedontane »

Posted in the hello forum
sedontane
Mouse
Mouse
Posts: 10
Joined: March 2nd, 2008, 14:24
Contact:

Post 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'.
Fear
Zombie
Zombie
Posts: 2032
Joined: August 6th, 2006, 21:45

Post 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
sedontane
Mouse
Mouse
Posts: 10
Joined: March 2nd, 2008, 14:24
Contact:

Post 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?
Fear
Zombie
Zombie
Posts: 2032
Joined: August 6th, 2006, 21:45

Post 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.
Baliame
Tremors Worm
Tremors Worm
Posts: 3491
Joined: October 13th, 2007, 23:43
Location: Hungary

Re: VB.Net

Post 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++.
sedontane
Mouse
Mouse
Posts: 10
Joined: March 2nd, 2008, 14:24
Contact:

Re: VB.Net

Post 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#
Post Reply