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

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

2013-11-13 10:21:09  來源: .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-2013 電腦知識網 Computer Knowledge   All rights reserved.