473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how do i delay the start of button function by 5 sec

547 512MB
I have a sound wav file that must first play for about 5 sec and then data must be added to a field only. Currently the sound start to play and a 1 second later the data is added to a table
My code i currently use is
Expand|Select|Wrap|Line Numbers
  1. Dim iRetValue As Long
  2.   iRetValue = sndPlaySound(CurrentProject.Path & "\Beepgunshot.wav", SND_ASYNC)
  3. [Forms]![racef]![TimeSF]![timestart] = Format(Now, "dd/MM/yyyy HH:nn:ss") & "." & Right(Format(Timer, "#0.00"), 2)
there is a module involved for the wav file

The attached file is in v2003
Attached Files
File Type: zip delaystart v 2003.zip (33.8 KB, 73 views)
Apr 8 '11 #1

✓ answered by neelsfer

got the delay right to the millisecond
Expand|Select|Wrap|Line Numbers
  1. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
and in the button code added this at right place to delay
Expand|Select|Wrap|Line Numbers
  1. Sleep 3900

8 1762
NeoPa
32,556 Expert Mod 16PB
I'm not familiar with the function sndPlaySound() but I think the clue is in the last parameter SND_ASYNC. You want the function to run synchronously of course.
Apr 9 '11 #2
neelsfer
547 512MB
got the delay right to the millisecond
Expand|Select|Wrap|Line Numbers
  1. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
and in the button code added this at right place to delay
Expand|Select|Wrap|Line Numbers
  1. Sleep 3900
Apr 9 '11 #3
NeoPa
32,556 Expert Mod 16PB
Did you not find the list of allowable parameters for sndPlaySound()? I can see your solution is a good one, but if you use the function as (I expect) it is designed for this scenario, you wouldn't even have the problem to need a clever solution. I can't find anything about it as it's not an Access function at all, but you must have it available in order to use it.

PS. The approach you use is open to failure if anything delays the processing of the sound. This may not be a big problem in your project, but surely less appropriate than running the sound synchronously in the first place.
Apr 9 '11 #4
neelsfer
547 512MB
Thx NeoPa. I searched the internet for your solution but could not find anything. Then came across this other solution. It seems to work fine for now.
Apr 9 '11 #5
NeoPa
32,556 Expert Mod 16PB
I'm not sure why you'd search the internet for it when you must have the library to hand anyway in order to use it, but that's by-the-by I suppose. If you're happy with that then who am I to worry.
Apr 10 '11 #6
neelsfer
547 512MB
Neopa i am still a beginner but learning fast. This project of mine has taught me so much already, and i am very great full to you and Adezi and others that regularly helped me so much in he last few months.My timing program is working brilliantly now and if you ever have people needing info on timing races, refer them to me by all means.
Neels
Apr 10 '11 #7
ADezii
8,834 Expert 8TB
For the record, NeoPa had the solution in Post #2, where he suggested that you execute the Sound File Synchronously. The syntax is:
Expand|Select|Wrap|Line Numbers
  1. Public Const SND_SYNC = &H0
Expand|Select|Wrap|Line Numbers
  1. Dim iRetValue As Long
  2.  
  3. iRetValue = sndPlaySound("C:\Test\Test.wav", SND_SYNC)
  4.  
  5. 'You will not see this Message Box until Test.wav has finished playing
  6. MsgBox "Sound completed!"
P.S. - I feel as though this is a much cleaner and more efficient approach.
Apr 10 '11 #8
NeoPa
32,556 Expert Mod 16PB
To be fair, missing the proper solution is often a cause of learning more about other areas and aspects. Neels has got some good experience of using delays and timers etc, even if this is not an appropriate place to use it.

PS. Thanks for the post ADezii.
Apr 10 '11 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dave | last post by:
Hi, This way to start a function works with IE; why doesn't it work with NS (7). <input type="button" id="test"> <script> function test.onclick() { .... }
0
by: Laurence Nuttall | last post by:
I have noticed that in .Net when I run the program, It moves the start button to the second row, How can I have it keep the start button on the first row. Thanks, Laurence Nuttall Programmer...
0
by: Kim Würtz | last post by:
Hi everybody I have a mission critical application, so I don't want the user to be able to start other apps on the PC like internet explorer etc. Therefore I want to hide the start button as...
2
by: news.microsoft.com | last post by:
I'm trying to write a program that will lock down the system. I want to hide the start button and taskbar. I found code using ShowWindow & FindWindow but they fail to work. Butttonhwnd =...
0
by: [Yosi] | last post by:
I search solution for a little bit strange problem , I working on an application which includes a button. Click on this button will create number of threads each one execute deferent executable...
6
by: Magic Gooddy | last post by:
Hi! How to hide Start Button in VB.NET? I know in VB6 and want to see this sample in VB.NET. Can anybody create worked sample?
3
by: Tee | last post by:
Hi, Can we use thread.start on a function that has return value? I have a function that will take sometimes to run and it will return a string value, and I want to use thread.start to call...
3
by: chris311976 | last post by:
I have a laptop it boots normally to xp i chose a user the windows desktop comes up with no start button icons or anything.I tried to go into safe mode etc but nothing works help!
10
by: thupham | last post by:
Dear all friend, I want disable Ctl+Alt+Del; Ctrl+Esc; Ctrl+tab, Alt+Tab, Start button, ctrl+Alt+Del, lock all keys on the keyboard. Have you ever do it in C#. Help me. Thanks for all reply.
0
by: visweswaran2830 | last post by:
I want to disable start button and alt+tab button using vb.net. Can any one help me. I tried with below coding but not success Option Explicit Private Declare Function EnableWindow Lib...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.