ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox.Visible = True ... not working (https://www.excelbanter.com/excel-programming/387475-textbox-visible-%3D-true-not-working.html)

Ozgur Pars[_2_]

TextBox.Visible = True ... not working
 
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

[email protected]

TextBox.Visible = True ... not working
 
Hi
Try putting in some "DoEvents" lines after making the buttons visible.
This often sorts out this kind of graphics updating problem. I didn't
look at your code in detail though, so it may be something else!
regards
Paul

e.g.
TextBox2.Visible = True
DoEvents


On Apr 16, 8:38 am, Ozgur Pars
wrote:
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




Ozgur Pars[_2_]

TextBox.Visible = True ... not working
 

Paul thanks for the reply will try it out and let you know about the result.

Özgür
" wrote:

Hi
Try putting in some "DoEvents" lines after making the buttons visible.
This often sorts out this kind of graphics updating problem. I didn't
look at your code in detail though, so it may be something else!
regards
Paul

e.g.
TextBox2.Visible = True
DoEvents


On Apr 16, 8:38 am, Ozgur Pars
wrote:
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





Ozgur Pars[_2_]

TextBox.Visible = True ... not working
 
Paul thank you very much it worked.

Özgür

" wrote:

Hi
Try putting in some "DoEvents" lines after making the buttons visible.
This often sorts out this kind of graphics updating problem. I didn't
look at your code in detail though, so it may be something else!
regards
Paul

e.g.
TextBox2.Visible = True
DoEvents


On Apr 16, 8:38 am, Ozgur Pars
wrote:
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






All times are GMT +1. The time now is 12:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com