|
-
Aug 26th, 2007, 11:10 AM
#1
Thread Starter
Lively Member
[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!
-
Aug 26th, 2007, 11:16 AM
#2
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.
-
Aug 27th, 2007, 12:06 PM
#3
Re: How to auto-click msgboxes?
 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."
-
Aug 27th, 2007, 01:55 PM
#4
Re: How to auto-click msgboxes?
Hmmm... Looks delicious!
-
Aug 26th, 2007, 11:31 AM
#5
Thread Starter
Lively Member
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:
For i = 1 to nTotal
Call SendData(i)
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:
For i = 1 to nTotal
Call SendData(i)
Msgbox i
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!
-
Aug 26th, 2007, 11:34 AM
#6
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.
-
Aug 26th, 2007, 12:02 PM
#7
Re: How to auto-click msgboxes?
DoEvents wouldn't do any good.
You may need to have some loop inside the SendData so you can get a confirmation of some kind after data is submitted succesfully.
-
Aug 26th, 2007, 12:01 PM
#8
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).
-
Aug 26th, 2007, 12:07 PM
#9
Re: How to auto-click msgboxes?
 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.
Last edited by RhinoBull; Aug 26th, 2007 at 12:12 PM.
-
Aug 26th, 2007, 12:07 PM
#10
Fanatic Member
Re: How to auto-click msgboxes?
would a pause not help?
vb Code:
Public Sub Pause(ByVal MilsecToWait As Long)
Dim lngEndingTime As Long
lngEndingTime = GetTickCount() + (MilsecToWait)
Do While GetTickCount() < lngEndingTime
DoEvents
Loop
End Sub
then in a sub you could have
Just a thought?
-
Aug 26th, 2007, 12:09 PM
#11
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.
-
Aug 26th, 2007, 12:39 PM
#12
Thread Starter
Lively Member
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. =)
-
Aug 27th, 2007, 09:18 AM
#13
Re: How to auto-click msgboxes?
How about using the Sleep API
vb Code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
For i = 1 to nTotal
Call SendData(i)
Sleep 500 'pause for one half second
Next i
-
Aug 30th, 2007, 09:13 AM
#14
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|