MegaMan
May 1st, 2002, 07:46 PM
Hello all you intelligent programmers! :cool:
I am a new programmer-- I sort of know my way around VB but im not to familiar with module programming, dll, ocx whatever.. but i had a quick question and just to double check my understanding of how classes work. So if you know and are able to answer please do so at your earliest convenience :-)
If i created a class called clsUser and defined some parameters
Public Name as string
Public LoggedIn as Boolean
so then I could use this class to create an object like this:
dim CurrentUser as clsUser
Set CurrentUser = New objUser
CurrentUser.Name = Joe
CurrentUser.LoggedIn = True
---- furthermore i could add a sub
Public Sub Bark()
MsgBox "woof woof"
End Sub
as a procedure or method of the clsUser object and reference like:
CurrentUser.Bark
so apparently Joe barked lol..
--- i just wanted to double check and see if what i understood about classes is correct..
ok I want to know how i can use for example CurrentUser.Name and pass that value to a sub within the same class module like this maybe:
Public Sub WhoBarked(byval person as string)
MsgBox person & " barked! "
End Sub)
and access it using the following method:
CurrentUser.Name = HisName
CurrentUser.WhoBarked(HisName)
When i do this the person's name shows up as blank or null.. but if i do this:
CurrentUser.WhoBarked("Steve")
Then the output is "Steve barked!"
how do i reference a variable or the value of a property for the current instance of that object??
THANKS SO MUCH FOR YOUR HELP!
Respond
:)HEY!
:)HEY!
I am a new programmer-- I sort of know my way around VB but im not to familiar with module programming, dll, ocx whatever.. but i had a quick question and just to double check my understanding of how classes work. So if you know and are able to answer please do so at your earliest convenience :-)
If i created a class called clsUser and defined some parameters
Public Name as string
Public LoggedIn as Boolean
so then I could use this class to create an object like this:
dim CurrentUser as clsUser
Set CurrentUser = New objUser
CurrentUser.Name = Joe
CurrentUser.LoggedIn = True
---- furthermore i could add a sub
Public Sub Bark()
MsgBox "woof woof"
End Sub
as a procedure or method of the clsUser object and reference like:
CurrentUser.Bark
so apparently Joe barked lol..
--- i just wanted to double check and see if what i understood about classes is correct..
ok I want to know how i can use for example CurrentUser.Name and pass that value to a sub within the same class module like this maybe:
Public Sub WhoBarked(byval person as string)
MsgBox person & " barked! "
End Sub)
and access it using the following method:
CurrentUser.Name = HisName
CurrentUser.WhoBarked(HisName)
When i do this the person's name shows up as blank or null.. but if i do this:
CurrentUser.WhoBarked("Steve")
Then the output is "Steve barked!"
how do i reference a variable or the value of a property for the current instance of that object??
THANKS SO MUCH FOR YOUR HELP!
Respond
:)HEY!
:)HEY!