一个简单的窗口,是一个倒计时程序,但后面那部分总是说我不合法出错,请各位朋友指点,先谢谢了。Dim m As LongPrivate Sub Command1_Click()
    Text1 = Val(Text1) * 60
    Timer1.Enabled = True
    Label1.Caption = "开始倒计时"
    Command1.Visible = False
End SubPrivate Sub Timer1_Timer()
    m = Val(Text1)
    m = m - 1
    If m < 0 Then
        Timer1.Enabled = False
        MsgBox "时间到!", 0, "倒计时"
        Label1.Caption = "请输入倒计时的分钟数"
        Text1 = ""
        Command1.Visible = True
        Exit Sub
    End If
    n1 = Format(m Mod 60, "00")
    n2 = Format((m Mod 60) Mod 60, "00:")
    n3 = Format(m Mod 3600, "00:")
    Text1=n3&n2&n1
    Command1.Visible = False
End Sub

解决方案 »

  1.   


    Dim m As Long
    Dim n1 As String, n2 As String, n3 As StringPrivate Sub Command1_Click()
        Text1 = Val(Text1) * 60
        Timer1.Enabled = True
        Label1.Caption = "&iquest;&ordf;&Ecirc;&frac14;&micro;&sup1;&frac14;&AElig;&Ecirc;±"
        Command1.Visible = False
    End SubPrivate Sub Timer1_Timer()
        m = Val(Text1)
        m = m - 1
        If m < 0 Then
            Timer1.Enabled = False
            MsgBox "&Ecirc;±&frac14;&auml;&micro;&frac12;&pound;&iexcl;", 0, "&micro;&sup1;&frac14;&AElig;&Ecirc;±"
            Label1.Caption = "&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;&micro;&sup1;&frac14;&AElig;&Ecirc;±&micro;&Auml;·&Ouml;&Ouml;&Oacute;&Ecirc;&yacute;"
            Text1 = ""
            Command1.Visible = True
            Exit Sub
        End If
        n1 = Format(m Mod 60, "00")
        n2 = Format((m Mod 60) Mod 60, "00:")
        n3 = Format(m Mod 3600, "00:")
        Text1 = n3 & n2 & n1
        Command1.Visible = False
    End Sub
      

  2.   

    n3 & n2 & n1
      

  3.   

    二楼的程序和我的没什么区别啊,我的程序应该是从倒数第6行那里开始错的,因为我不懂用format函数啊
      

  4.   

    没有错误啊!!Option ExplicitDim m As LongPrivate Sub Command1_Click()
        Text1 = Val(Text1) * 60
        Timer1.Enabled = True
        Label1.Caption = "开始倒计时"
        Command1.Visible = False
    End SubPrivate Sub Timer1_Timer()
        Dim n1 As String, n2 As String, n3 As String
        m = Val(Text1)
        m = m - 1
        If m < 0 Then
            Timer1.Enabled = False
            MsgBox "时间到!", 0, "倒计时"
            Label1.Caption = "请输入倒计时的分钟数"
            Text1 = ""
            Command1.Visible = True
            Exit Sub
        End If
        n1 = Format(m Mod 60, "00")
        n2 = Format((m Mod 60) Mod 60, "00:")
        n3 = Format(m Mod 3600, "00:")
        Text1 = n3 & n2 & n1
        Command1.Visible = False
    End Sub