Results 1 to 14 of 14

Thread: [RESOLVED] How to auto-click msgboxes?

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Resolved [RESOLVED] How to auto-click msgboxes?

    Hello friends, I have this problem. In my program, I have added a msgbox for every count in a certain loop.

    For Example:

    For i = 1 to nTotal
    Msgbox i
    Next i


    Is there anyway to auto-click the msgbox (by means of program code) to get rid of them?

    Thanks for all the help!

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to auto-click msgboxes?

    The puepose of showing message boxes is to notify user of something important that happend durring execution.
    In your case it's absolutely pointless so if you need that for debugging purpose then use Debug.Pint instead.

    However, you may pop your own form (modally) instead of using msgbox function so you can (perhaps using timer) close that form after few seconds.

  3. #3
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: How to auto-click msgboxes?

    Quote Originally Posted by RhinoBull
    . . . for debugging purpose then use Debug.Pint instead . . .

    Hey Rhino, were you at the pub when you typed this?
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  4. #4

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: How to auto-click msgboxes?

    Actually I'm msgboxing because it's the only method I can get my program to work. You see, my program is supposed to send out data to the various clients as follows:

    vb Code:
    1. For i = 1 to nTotal
    2.    Call SendData(i)
    3. Next i

    However, when I try to run the code, it loops so fast that some of the clients do not receive the data. In fact, only the first person off my client list will receive the data successfully. The rest of the clients do not receive anything. However everything worked out fine when I debug the following code:


    vb Code:
    1. For i = 1 to nTotal
    2.    Call SendData(i)
    3.    Msgbox i
    4. Next i

    I manually closed the msgboxes one by one, and the clients all received the data successfully. Next, I held down the enter key, and again the clients received the data successfully.

    So what I'm guessing is that if the program code is allowed to loop without any delay, the lan connection is not fast enough to send out the data to the various clients successfully, some sort of data loss. However, with the msgboxes, a small window of delay is created (even with the enter button held down), which allows for the smooth sending of data to the various clients.

    So that's why I asked if there is any way to automate the process of closing these msgboxes, because I don't want the user end to manually close these msgboxes.

    Thanks for the help!

  6. #6
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: How to auto-click msgboxes?

    Use doevents. Ex

    Code:
          For i = 1 to nTotal
             Call SendData(i)
             DoEvents
          Next

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  7. #7

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to auto-click msgboxes?

    My guess is that you have a buggy version of VB6. If not at SP6 install the latest service pack, recompile, redistribute the compiled program with all dependencies.

    "Speed of the LAN" isn't relevant. The outgoing data is buffered if you're using the Winsock control (though you did not say that).

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to auto-click msgboxes?

    Quote Originally Posted by dilettante
    My guess is that you have a buggy version of VB6...
    What does it have to do with VB at all?
    He's executing some function too fast while looping and that is the problem. So you need to delay for a little bit.

  10. #10
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Re: How to auto-click msgboxes?

    would a pause not help?
    vb Code:
    1. Public Sub Pause(ByVal MilsecToWait As Long)
    2.     Dim lngEndingTime As Long
    3.     lngEndingTime = GetTickCount() + (MilsecToWait)
    4.     Do While GetTickCount() < lngEndingTime
    5.         DoEvents
    6.     Loop
    7. End Sub
    then in a sub you could have
    vb Code:
    1. Pause 500

    Just a thought?

  11. #11
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to auto-click msgboxes?

    There are numerous bugs in the Winsock control that were fixed in later service packs. Many of them relate to using multiple Winock controls and multiple connections.

    However I'm only assuming that he's even using Winsock controls here.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: How to auto-click msgboxes?

    Yes, I'm using Winsock controls in my program. There are multiple connections too for this and maybe you're right, it's the buggy Winsocks.

    I'll try the suggestions you guys came up with tomorrow and I'll get back asap. Once again thanks a lot for all the help, you guys are a great bunch of people. =)

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to auto-click msgboxes?

    How about using the Sleep API
    vb Code:
    1. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    2.  
    3. For i = 1 to nTotal
    4.    Call SendData(i)
    5.    Sleep 500 'pause for one half second
    6. Next i

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: How to auto-click msgboxes?

    Yeah, both the pause sub and the sleep API worked fine! Thanks a whole lot you guys! =)

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