重置属性不起作用

时间:2014-04-11 14:14:55

标签: vb.net

由于某种原因,我的重置时间不起作用。这部分代码,我希望它基本上做它说它正在做的事情,我正在检查txt框是否为数字

If timeM = (txtWDM.Text + txtRDM.Text) And timeS = (txtWDS.Text + txtRDS.Text) Then
    timeS = 0
    timeM = 0
End If

这是整个代码,有人可以帮我修复我的代码,谢谢

Private Sub timClock_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timClock.Tick
    'Plays the go sound
    If timeM = 0 And timeS = 0 Then
        My.Computer.Audio.Play(My.Resources.Beep_Go, AudioPlayMode.Background)
    End If
    'if Time in seconds below 9 then add 0 to the start of the label
    If timeS < 9 Then
        timeS += 1
        lbltime.Text = timeM & ":0" & timeS
        'If above 9 then make it normal timeS
    Else
        timeS += 1
        lbltime.Text = timeM & ":" & timeS
        'If Seconds are 60 then Add 1 to Minutes and reset Seconds
        If timeS = 60 Then
            timeM += 1
            timeS = 0
            lbltime.Text = timeM & ":0" & timeS
        End If
        'If rest period is reached play Rest Sound
        If timeM = txtWDM.Text And timeS = txtWDS.Text Then
            My.Computer.Audio.Play(My.Resources.Beep_Stop, AudioPlayMode.Background)
        End If
        'If Rest period over then Reset process abd go back to play start sound
        If timeM = (txtWDM.Text + txtRDM.Text) And timeS = (txtWDS.Text + txtRDS.Text) Then
            timeS = 0
            timeM = 0
        End If
    End If
End Sub

1 个答案:

答案 0 :(得分:0)

使用CInt

  If timeM = (CInt(txtWDM.Text) + CInt(txtRDM.Text)) And timeS = (CInt(txtWDS.Text) + CInt(txtRDS.Text)) Then
        timeS = 0
        timeM = 0
    End If

另外,不要像手动配置小时和分钟那样创建自己的时间管理方式。看看Custom Date and Time