Making VBA Form TextBox accept Numbers only (including +, - and .)

后端 未结 7 1220
生来不讨喜
生来不讨喜 2020-12-01 21:46

I have simple textBox and I want to validate its input including \"+\" , \"-\" and \".\" here is what I have tried

Private Sub DisplayValue_TextBox_Change()         


        
相关标签:
7条回答
  • 2020-12-01 22:33

    Im using that:

    Private Sub txtGiaNet_Change()
        If IsNumeric(txtGiaNet.Value) Then
            //if number do sth
        Else
            //if not, delete this character
            txtGiaNet.Value = Left(txtGiaNet.Value, Len(txtGiaNet.Value) - 1)
        End If
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题