Results 1 to 9 of 9

Thread: Procedure return

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Procedure return

    Hi , i got some situation over here.
    I have PROCEDURE (A) that set public, when PROCEDURE (A) call i pass to it some obejct on FORM where PROCEDURE (A) being call.
    When the PROCEDURE (A) end i want the PROCEDURE (A) to call some FUNCTION or PROCEDURE (B) reside on the FORM where this public PROCEDURE (A) beeing call. On this PROCEDURE (B), i'm going to change some other control that FORM.

    How i do that?

    Please help

  2. #2
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Procedure return

    your logic is very confusing, can you explain your argument clearly. i suggest you dont hide sime info of your project coz you cant get any help if you hide it and present a confusing problem here on the forums
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Procedure return

    Sorry, i got nothing to hide but my english is really bad...

    I want before procedure from module that set public end, it execute some procedure from FORM where the public procedure being call.

    I'm moving from Clipper to VB, with Clipper i can do this easily.
    using clipper logic, it's should this way:

    VB Code:
    1. Private sub FORM1_load()
    2.     call hitung
    3.     call test
    4. end sub
    5.  
    6. Private sub TEST()
    7.     tetxbox1.text="BLAH BLAH"
    8.     ' and change some other control on FORM`
    9. End Sub
    10.  
    11. 'on module part with name ABCD
    12. public sub Hitung()
    13.     'do whatever
    14. end sub

    "test" procedure will be call only when "hitung" procedure finish.
    or how to call "test" procedure form module "ABCD"

    VB Code:
    1. 'on module part with name ABCD
    2. public sub Hitung()
    3.     'do whatever
    4.     FORM1.test
    5. end sub

    I think i'm missing something really basic here.

    Please help.

    PS: Forget to mention, i'm using MDI Form. So FORM1 can be open more than one.
    Last edited by barianto; Jul 27th, 2006 at 10:40 PM.

  4. #4
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Procedure return

    i see no problem with your code

    you can also do that like this
    VB Code:
    1. Private sub FORM1_load()
    2.     hitung
    3.     test
    4. end sub

    of

    VB Code:
    1. Private sub FORM1_load()
    2.     hitung
    3. end sub
    4.  
    5. Private sub TEST()
    6.     tetxbox1.text="BLAH BLAH"
    7.     ' and change some other control on FORM`
    8. End Sub
    9.  
    10. 'on module part with name ABCD
    11. public sub Hitung()
    12.     'do whatever
    13.     text
    14. end sub
    you need not to use call since these are just procedures and not functions
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Procedure return

    Using method number 1- Problem arise because "test" will execute after "hitung" being excecute not after "hitung" finished.

    Using method number 2-
    I'm using MDI FORM
    I'm calling MDI child FORM MDI Main

    VB Code:
    1. Dim frm As FORM1
    2.             Set frm = New FORM1
    3.             Set frm.fMain = Me
    4.             frm.Show
    5.             Set frm = Nothing
    6.  
    7.            
    8.              'on FORM1
    9.             Public fMain As frmMain
    10.             'where  frmMain are name MDI Main

    when i'm calling "test" it give me error to all object/control on FORM1 that reference to frmMain. I have imagelist on frmMain that i accessing from FORM1 and some other thing.

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Procedure return

    Quote Originally Posted by barianto
    Using method number 1- Problem arise because "test" will execute after "hitung" being excecute not after "hitung" finished.
    That was confusing... After it has been executed means that it has finished. When you call a procedure the execution will not continue until that procedure has finished its job.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Procedure return

    upps, my fault
    the "hitung" procedure was detect mouse movement.

    Joacim,
    actually "hitung" procedure is mousehook procedure you give me the other day.
    And what i want is when it is click outside the area, i want it to call some function/procedure on FORM1.

    How to do that?
    Attached Files Attached Files

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Procedure return

    Aha, I see. Well, since the callback procedure that the mouse hook is using is called by Windows it's actually called by another thread then the one you're running and trying to access your Form from such a callback procedure will crash your program.

    But since that is showing a Frame and you want to call the next procedure after the Frame is "closed" simply loop and check if the frame is visible or not.

    First add the following to the General Declaration section of your Form:
    VB Code:
    1. Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    Then use code simular to this:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Call HookMouse(Me.hWnd, Frame1.hWnd)
    3.     'loop while the frame is visible
    4.     Do While Frame1.Visible
    5.         Call Sleep(1)
    6.         DoEvents
    7.     Loop
    8.     CallTheNextProcedureHere
    9. End Sub

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Procedure return

    Joacim that's do what i want.
    Again you save my day.

    Thanks d3gerald, joacim.

    You guy have any rerefence/book that can give me idea to solve this kind of problem?

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