[VBA] 只限輸入數字

[VBA] 只限輸入數字

記下來

在KeyPress事件中判斷輸入的Ascii即可,http://www.asciitable.com/


Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 46) = False Then
       KeyAscii = 0
    End If
End Sub

.Net的限制輸入在這裡

http://www.dotblogs.com.tw/chou/archive/2009/07/31/9774.aspx

若有謬誤,煩請告知,新手發帖請多包涵


Microsoft MVP Award 2010~2017 C# 第四季
Microsoft MVP Award 2018~2022 .NET

Image result for microsoft+mvp+logo