Re: How do I use this Class I made?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



You must first create an instance of a class before you can access it`s
property`s or methods ( unless it is declared shared but that`s another
chapter )

so the syntax for your example would be



Private Sub btnFrown_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFrown.Click
dim oFaces as new Faces
lblface.text = ofaces.frown
End Sub


regards

Michel Posseth







"Ron" <pts4560@xxxxxxxxx> schreef in bericht
news:1169493809.373755.235910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am writing a very simple program, three buttons NORMAL, SMILE, FROWN.
When the appropriate button is clicked a label either pops up a smile,
frown or a normal face.

I wrote a class to do this. Using the Windings font and the letts J K
L you can get faces.

How do I then use this class for my button click events?

Here is my class:
Public Class Faces
Private s As String = "J"
Private n As String = "K"
Private f As String = "L"

Public ReadOnly Property smile() As String
Get
Return s
End Get

End Property
Public ReadOnly Property normal() As String
Get
Return n
End Get
End Property
Public ReadOnly Property frown() As String
Get
Return f
End Get
End Property
End Class

NOW lets say I want to use that class on this frown button click event?
How would the code look? I was thinking :
Public Class Form1
Private Sub btnFrown_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnFrown.Click

lblface.text = faces.f

End Sub

BUT This does not work. Anyone can tell me how to get this to work?
Do I need to do something before my class will work?



.


Quantcast