|
-
Jul 4th, 2001, 10:15 PM
#1
Thread Starter
Frenzied Member
how can a module know which form called?
Hi all.
WIth out Select case or public variables, is there a property that the module can use to generically refer to the form that called it?
example like so:
'module
Public Sub changefont(frmWhatever as form)
frmWhatever.Text1.font = "Arial"
end sub
'form
Form_Load()
changefont(Me)
end sub
Something like that?
This doesnt work because it returns type mismatch
also name of the form doesnt work as argument
possible?
Thanks
Wengang
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Jul 4th, 2001, 10:19 PM
#2
worked for me under a command button click, try putting it in Form_Activate, instead of Load
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 4th, 2001, 10:26 PM
#3
Thread Starter
Frenzied Member
but i'm continuing to get type mismatch
under buttonclick
formload
and formactivate
what did you pass as the argument?
me?
Form1?
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Jul 4th, 2001, 10:30 PM
#4
here is what I have :
VB Code:
' in Module1
Public Sub dothis(ff As Form)
ff.Text1.Text = "Hello"
End Sub
'in Form1
Private Sub Command1_Click()
dothis Me
End Sub
and it works with no trouble
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 4th, 2001, 10:32 PM
#5
alright, I now notice that is was the font that is to be changed.
try Text1.Font.Name
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 4th, 2001, 10:41 PM
#6
Here is an easy way. ByRef changes the source textbox.
Code:
Public Sub ChangeFont(ByRef txtBox As TextBox)
txtBox.Font = "Arial"
End Sub
' Usage
ChangeFont Text1
-
Jul 4th, 2001, 10:43 PM
#7
Thread Starter
Frenzied Member
so the error was here
myfunction(me)
should be
myfunction me
yes, it works even in the form_load event
thanks so much!!
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
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
|