|
-
Jul 7th, 2006, 11:11 PM
#1
Thread Starter
New Member
Using a Label within a class
Hi, what I'm trying to do here is allow the user on the actual form to enter the number of 'Count' (that's what the class is called) to be made. It receives a value for the variable 'Name', then allots it to Labelx.Text. Then, I would like Labelx to appear on the actual form, but it does not. Can anyone tell me why? This code should actually be pretty simple for experience programmers, but unfortunately I am not. Please excuse the redundancy of my code, for I can clear that up later.
Public Class Count
' Option Explicit On - needed?
Dim Name As Integer
Dim Number As Integer
Dim IsBeat As Boolean
Public Sub Set_Number(ByVal Number As Integer)
Number = Number
Name = CStr(Number)
End Sub
Public Function Get_Number()
Dim Labelx As New Label
Labelx.Size = New System.Drawing.Size(50, 50) ' Is this needed?
Labelx.Location = New System.Drawing.Point(100, 100) ' Is this needed?
Labelx.Text = Name
Labelx.Visible = True
End Function
End Class
Best regards,
Ben.
-
Jul 7th, 2006, 11:47 PM
#2
Addicted Member
Re: Using a Label within a class
Hi
add this code at the end of Get_Number()
Hope this helps...
Regards
=======================================
If I helped you, Kindly Rate my post. Thanks
-----------
PHENOM 
-
Jul 7th, 2006, 11:52 PM
#3
Hyperactive Member
Re: Using a Label within a class
Won't work as you have it...try this
VB Code:
'on a form
Dim myCount As New Count
Me.Controls.Add(myCount.Get_Number())
'class
Public Function Get_Number() As Label
Dim Labelx As New Label
Labelx.Size = New System.Drawing.Size(50, 50) ' Is this needed?
Labelx.Location = New System.Drawing.Point(100, 100) ' Is this needed?
Labelx.Text = Name
Labelx.Visible = True
Return Labelx
End Function
Last edited by gtilles; Jul 7th, 2006 at 11:56 PM.
Truly, you have a dizzying intellect.
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
|