熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

限制文本框的輸入(只輸入數字)

2022-06-13   來源: .NET編程 

  文本框防止非法字符輸入

  只輸入整數
    Private Sub Text_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
    Case Asc(\\) To Asc(\\) vbKeyBack
    \nop
    Case Else
    KeyAscii =
    End Select
    End Sub

  只輸入小數:

  Private Sub Text_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
    Case Asc(\\) To Asc(\\) vbKeyBack
    \nop

  case Asc(\\)\允許一個小數點
    If InStr( TextText \\) > Then KeyAscii =

  Case Else
    KeyAscii =

  End Select
    End Sub


From:http://tw.wingwit.com/Article/program/net/201311/13347.html
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.