Y TestBox don't Change?

S

Soniya

Hi All,

The following code I recieved from this newsgroup:

Private Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub PlayWavFile(WavFileName As String, Wait As Boolean)
If Dir(WavFileName) = "" Then Exit Sub ' no file to play
If Wait Then ' play sound before running any more code
sndPlaySound WavFileName, 0
Else ' play sound while code is running
sndPlaySound WavFileName, 1
End If
End Sub

Now I am trying to play a sound file and change TextBox Text from the
following, but text box dont change.

under the CmbRef change I have code to change the text in TextBox1.
I know the CmbRef changes and the coresponding sound file is played but
for some reason it is not displaying the text in the textbox.

What I am trying to do is that play display a text in textbox and play
a sound file according to user selection in combobox CmbRecF
(starting) and combobox CmbRecT(ending). based on this selection in my
sheet1 column A text is displayed in textbox and sound played.

I have all those thing working properly excepet the display of
corresponding text while playing the sound.

Sub TestSoundFile()
Dim WAVFile As String
Dim v As Variant
Dim Y, Z As Variant
v = Split(CmbRef, ":")
Y = Format(v(0), "000")
Z = Format(v(1), "000")
WAVFile = Y & z & ".wav"
WAVFile = "D:\Folder\Mele\" & WAVFile

PlayWavFile WAVFile, True

End Sub


Private Sub CmdSound_Click()
Application.ScreenUpdating = True
If CmbRecT.ListIndex < CmbRecF.ListIndex Then
CmbRecT = CmbRecF
End If
Do While CmbRef <= CmbRecT

TestSoundFile
If CmbRef = CmbRecT Then Exit Sub

CmbRef.ListIndex = CmbRef.ListIndex + 1
Application.Wait (Now + TimeValue("0:00:01"))

Loop
End Sub


Thanks
 
B

Bob Phillips

You are probably not setting the filenames correctly.

Add some debug code, such as a Msgbox showing the variable values to see
what the value is.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
S

Soniya

When Added this:
after >>> CmbRef.ListIndex = CmbRef.ListIndex + 1

MsgBox ("Now the Text shud change")

it shows the msgbox and changes the text box...
I know it changes but not get displayed in the text box.
because the sound changes and the the fist two cells show then last
cell value is shown in the text box. it fails to display from third
onwards..

I tried to set ScreenUpdating to true still not working...
Code works, but the text not displyed..

thanks..!
 
B

Bob Phillips

Try adding stuff like

MsgBox CmbRef.Value

and so on to check what values are being passed around.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
S

Soniya

Thanks for your reply...

When I put MsgBox CmbRef.Value I Could see exactly those texts what I
needed. I know CmbRef changes since the the sound file name is taken
from the CmbRef.value and all sounds are played well. But CmbRef.change
event has the code to show the corresponding text which is not shown
prperly. It displayes first two and then the last.

If I manually change CmbRef.value then all the texts shown properly.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top