Results 1 to 5 of 5

Thread: Can someone explain

  1. #1
    Kenny_Dee
    Guest

    Can someone explain

    I have a piece of code that will be used by 18 different forms. Can someone post a quick example of how and ware i would put the code in only one place so all forms can call it.

    Thanks

  2. #2
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    Why not place your code in a module and have each form call it.

    Mega.
    "If at first you don't succeed, then skydiving is not for you"

  3. #3
    Kenny_Dee
    Guest

    that is what I want to do

    That is what I want to do, but I have never done that. I just wanted a quick example of how to set it up and what the command is to call it. Thats all

    Thanks

  4. #4
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    In a module, you can define subs and functions like this:
    {The examples are meant for illustration only}

    Public Function YourFunctionName(ByVal hwnd3 As Long, ByVal lParam As Long) As Long
    ..............
    End Function

    Or,
    Public Sub ....
    ....
    End Sub

    The above can be called from any form, no problem.

    Now, you can do the same on a forms code area,
    and when you want to use it from another form,
    Just reference its parents form, followed by a period, then the function or sub name.

    ie....
    Call Form1.MySubName


    -Hope this Helps
    -Lou

  5. #5
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    Create a new module in your project and we will call it modFormcode

    In the modules code type the following

    Public sub frmEvent()

    .....code goes here...

    End sub

    Then in the forms event that you want to trigger just place the command
    frmEvent and that will pass control to the module. When the module has finished, control will be passed back to the form.

    Mega.
    "If at first you don't succeed, then skydiving is not for you"

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