O
Ozgur Pars
Hi there,
I use the code below to show some textboxes and images while I play a sound
( explaining these images)... the problem that I can't solve is that
sometimes the code works and sometimes not. The sounds are correct all the
time but sometimes after the first textbox the other objects remain
invisible. At the end the first textbox turn invisible so that part works
too.
I patched this together from the net and my VBA is not good enough to single
out the mistake here and I would appreciate any help.
Thank you,
Özgür
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Private Sub Label2_Click()
If CheckBox1.Value = True Then
TextBox2.Visible = True
WAVFile = "Scenario2.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 18
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
TextBox3.Visible = True
Image3.Visible = True
WAVFile = "Scenario3.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 15
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Image3.Visible = False
Image2.Visible = True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 3
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
TextBox2.Visible = False
TextBox3.Visible = False
Image2.Visible = False
Image3.Visible = False
End If
newHour = ""
newMinute = ""
newSecond = ""
End Sub
I use the code below to show some textboxes and images while I play a sound
( explaining these images)... the problem that I can't solve is that
sometimes the code works and sometimes not. The sounds are correct all the
time but sometimes after the first textbox the other objects remain
invisible. At the end the first textbox turn invisible so that part works
too.
I patched this together from the net and my VBA is not good enough to single
out the mistake here and I would appreciate any help.
Thank you,
Özgür
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Private Sub Label2_Click()
If CheckBox1.Value = True Then
TextBox2.Visible = True
WAVFile = "Scenario2.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 18
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
TextBox3.Visible = True
Image3.Visible = True
WAVFile = "Scenario3.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 15
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Image3.Visible = False
Image2.Visible = True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 3
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
TextBox2.Visible = False
TextBox3.Visible = False
Image2.Visible = False
Image3.Visible = False
End If
newHour = ""
newMinute = ""
newSecond = ""
End Sub