format
具体用法不知,谁来说说??或在TEXTBOX的属性设置窗口中设置。

解决方案 »

  1.   

    可以再text的change事件里写入用于判断输入的程序代码。
      

  2.   

    在TEXT.text的change事件里加判断试试
      

  3.   


    Text1.MaxLength = 2Private Sub Text1_KeyPress(KeyAscii As Integer)
                If KeyAscii < Asc(" ") Then     ' Is this Control char?
            Exit Sub                    ' Yes, let it pass
        End If    If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
            ' keep digit
        ElseIf KeyAscii = Asc(".") Then
            ' keep .
        ElseIf KeyAscii = Asc("-") Then
            ' Keep - only if first char
        Else
            KeyAscii = 0                ' Discard all other chars
        End IfEnd Sub
      

  4.   


    使用like语句好像是 text1.text like "*.__"把,我忘记了
      

  5.   

    GLAY(Micromort (C) 2002) :
    你的方法不行,用户要是输入37238-348.3434.234这种就无法判断。
    我要的是用户只能输入*.__这样格式的值,如果即将输入的字符会破坏这种格式,那么就禁止。
    shawls(小山)(无业游民)(VB版的众矢之的) :
    谢谢,我忘了这个方法,试一试。
      

  6.   

    Private sub text1_change()
    text1.text=format(text1.text,"##############0.00")
    End sub
      

  7.   

    我曾经因为一个软件上要用N个这样货币输入框,于是自己干脆做了个这样的控件,专用于输入货币,挺好用的。需要的话请联系我EMAIL给你。
    [email protected]
      

  8.   

    我想是这样,不知可否:Private Sub Text1_KeyPress(KeyAscii As Integer)
    Dim potpos As Integer
        If KeyAscii = 13 Then '判断是否键入回车
            If Text1.Text Like "*.##" Then
                Text1.Text = Text1.Text
            Else
                potpos = InStr(Text1.Text, ".") '定位“.”的位置
                If potpos > 0 Then
                 Text1.Text = Left(Text1.Text, potpos + 2)
                ElseIf potpos = 0 Then
                 Text1.Text = Text1.Text & ".00"'如无小数,则补上两位小数
                End If
            End If
        End If
    End Sub