|
-
Feb 20th, 2002, 12:04 AM
#1
Thread Starter
Lively Member
So simple.....but can't do it ...sheeeeee
hello intelligent people,
Simple problem.....
I have a class (compiled it to make dll).
It has one property (nm) and one method (rtn).
I am setting this property as "abhay" in my code, which will get converted to "ABHAY". (simple Ucase function).
Now, i want to display a messagebox saying "Got abhay" if
value of nm is "ABHAY".
Problem is, method rtn in class is not getting value of property nm.
Little jumbling? c the code below.
CLASS CODE
Public Property Get nm() As String
nm = myname
End Property
Public Property Let nm(ip As String)
myname = UCase(ip)
End Property
Public Sub rtn()
If ip = "abhay" Then
MsgBox "got it"
End If
End Sub
Follows is a code, where i set property of nm.
CODE
Private Sub Command1_Click()
Dim ab As New nmclass
ab.nm = "abhay"
ab.rtn
End Sub
Money is a great thing, but it can't purchase satisfaction....
Respect money, but don't allow it to control you...
-
Feb 20th, 2002, 12:07 AM
#2
PowerPoster
In your rtn sub:
Public Sub rtn()
If ip = "abhay" Then
MsgBox "got it"
End If
End Sub
you are checking ip, but that is just a parameter of the other functions. Shouldn't that be:
Public Sub rtn()
If myname = "abhay" Then
MsgBox "got it"
End If
End Sub
?
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Feb 20th, 2002, 12:08 AM
#3
PowerPoster
If you had 'Option Explicit' at the very top of your code, you'd have seen this for yourself, as it would have reminded you that in the second sub, ip had not been declared.
Always use Option Explicit.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Feb 20th, 2002, 12:41 AM
#4
Addicted Member
Private Sub Command1_Click()
Dim ab As New nmclass
ab.nm = "abhay"
ab.rtn
End Sub
It looks like you arent properly setting your class. I could be wrong, but try this code:
[code]
Private Sub Command1_Click()
Set ab = New nmclass
'etc, etc.
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
|