Results 1 to 7 of 7

Thread: how can a module know which form called?

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    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

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  3. #3

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    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

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    here is what I have :
    VB Code:
    1. ' in Module1
    2. Public Sub dothis(ff As Form)
    3.  
    4. ff.Text1.Text = "Hello"
    5.  
    6. End Sub
    7.  
    8. 'in Form1
    9. Private Sub Command1_Click()
    10.  
    11. dothis Me
    12.  
    13. 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

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  6. #6

  7. #7

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    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
  •  



Click Here to Expand Forum to Full Width