|
|
 |
'Create an object of class CText
Dim objCText As New CText
'************************************
'Handle Our Private Class Variable
'************************************
Private Sub Command2_Click()
objCText.Set_String (Text1.Text)
End Sub
Private Sub Command1_Click()
Text2.Text = objCText.Get_String
End Sub
'************************************
'Handle Our Public Class Variable
'************************************
Private Sub Command3_Click()
Text3.Text = objCText.mText2
End Sub
Private Sub Command4_Click()
objCText.mText2 = Text4.Text
End Sub
|
 |
'Private Variables
'can not be accessed outside the class
'It is private for the class
'We have to make Get and Set functions to edit them
Private mText As String 'Private Variable
'''''''''''''''''''''''''''''''''''''''''''''''''''
'Public Variables can be accessed through
'a class object
Public mText2 As String 'Public Variable
Private Sub Class_Initialize() 'Class Constructor
mText = "Jimi Hendrix 1968" 'Private value
mText2 = "Leo Fender 1957" 'Public value
End Sub
Public Sub Set_String(str As String)
mText = str 'set new value
End Sub
Public Function Get_String() As String
Get_String = mText 'get and return value
End Function
|
 |
Visual Basic Source Code |
I hope you found this Visual Basic tutorial useful!
Don't forget to mention Apron Tutorials in your References!
Best Regards
Ronny André Reierstad
|
|
|