|
-
Jan 20th, 2002, 05:09 AM
#1
Thread Starter
Hyperactive Member
Class Module Question
What i want to do is when i click on cmdBla that will call a function in my class module which will HIGGHLIGHT the text located in the textbox. This is what i am have, and what i am trying.
cmdBla
----------
HighlightTextBox(txtWineTypeName)
CLASS MODULE
------------------------
Private Function HighlightTextBox(oSelect As Object)
oSelect.SetFocus
oSelect.SelStart = 0
oSelect.SelLength = Len(oSelect.Text)
End Function
-----------------------------------------------------------------------------
Now that is not doing what its suppose to . Any way all help would be apreciated THX.
-
Jan 20th, 2002, 05:12 AM
#2
Have you instanciated an object of your class?
VB Code:
Private obj As YourClassName
Private Sub Form_Load()
Set obj = New YourClassName
End Sub
Private Sub cmdBla()
obj.HighlightTextBox txtWineTypeName 'you cant use parantheses here if this isnt a function
End Sub
Best regards
-
Jan 20th, 2002, 05:21 AM
#3
Thread Starter
Hyperactive Member
Just tried it that way :)
It didn't work for me that way i tried to work around it as well but nothing, . Thx for the help anyway.
Where it gives me the error ir right away in form load, the error says
Set oSelect = New CWineModule
it highlights Oslect and says
Variable Not Defined
Last edited by Tequila_worm; Jan 20th, 2002 at 05:35 AM.
-
Jan 20th, 2002, 05:33 AM
#4
When you're passing an object or a control to a sub you can't use parantheses because you will then pass it ByVal instead of ByRef.
(As mentioned in the comments of my earlier post).
Best regards
-
Jan 20th, 2002, 06:15 AM
#5
Did you declare a variable oSelect in your form first before you set it? Should be kinda like this:
VB Code:
'In the form
dim myObj as CWineModule
Set myObj=New CWineModule
myObj.HighlightTextBox txtWineTypeName
'then in the class module CWineModule
Public Sub HighlightTextBox(oSelect As Textbox)
oSelect.SetFocus
oSelect.SelStart = 0
oSelect.SelLength = Len(oSelect.Text)
End Sub
Make sure any subs or functions you want to call from the class are public and as long as its a class in the project not a dll you can pass the object as a textbox instead of the generic object., also since you don't return anything you'd make it a sub instead of a function.
-
Jan 20th, 2002, 02:26 PM
#6
Thread Starter
Hyperactive Member
Thanks for the help
That was it man, they had to be a Public function, holly crap man thx for you help.
Last edited by Tequila_worm; Jan 20th, 2002 at 02:31 PM.
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
|