记录直到值小于75 [英] Record until value is less than 75
本文介绍了记录直到值小于75的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用计时器进行记录,直到进度条的值下降到一定水平以下然后保存.我的问题是它可以将每次录制保存多次.底部的两个计时器用于记录和保存.
I want to use a timer to record until the value of a progressbar drops below a certain level then save. The problem I have is it saves each recording several times. The two timers at the bottom are for recording and saving.
Public Sub Record()
Dim result As Long
Try
result = mciSendString("open new Type waveaudio Alias recsound", "", 0, Nothing)
result = mciSendString("record recsound", "", 0, 0)
Catch ex As Exception
End Try
End Sub
Public Sub StopAndSave()
Dim formatteddate As String
formatteddate = DateTime.Now.ToString("MMddyyyyHHmmss")
Dim Filetosave As String = "save recsound " & ("c:\" & formatteddate & ".wav")
mciSendString(Filetosave, "", 0, 0)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.ProgressBar1.Value > 80 Then
Record()
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Me.ProgressBar1.Value < 80 Then
StopAndSave()
Else
End If
End Sub
推荐答案
保存时,需要停止计时器.
为什么要有两个计时器,这根本没有任何意义.
如果进度条为80,会发生什么?
When you save, you need to stop your timer.
Why have two timers, anyhow, that makes no sense at all.
What happens if the progress bar is at 80 ?
我尝试了许多不同的变体,包括一个计时器,但无法弄清楚.
知道如何用一个计时器发声吗?
I tried many different variations including only one timer but couldn''t figure it out.
Any idea how to word with one timer?
我想我明白了.这似乎很完美
I think I got it. This seems to work perfect
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.ProgressBar1.Value >= 80 Then
Record()
ElseIf Me.ProgressBar1.Value < 80 Then
Me.Timer1.Enabled = True
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Me.ProgressBar1.Value < 80 Then
Me.Timer1.Enabled = False
StopAndSave()
CloseAudio()
Else
End If
Me.Timer1.Enabled = True
End Sub
这篇关于记录直到值小于75的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文