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

 

 

 

程式  在textbox的觸發事件   KeyPress

 

 

Private Sub outgap_set_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles outgap_set.KeyPress
'e.KeyChar == (Char)48 ~ 57 -----> 0~9
'e.KeyChar == (Char)8 -----------> Backpace
'e.KeyChar == (Char)13-----------> Enter
If e.KeyChar = Chr(48) Or e.KeyChar = Chr(49) Or e.KeyChar = Chr(50) Or e.KeyChar = Chr(51) Or e.KeyChar = Chr(52) Or e.KeyChar = Chr(53) Or e.KeyChar = Chr(54) Or e.KeyChar = Chr(55) Or e.KeyChar = Chr(56) Or e.KeyChar = Chr(57) Or e.KeyChar = Chr(13) Or e.KeyChar = Chr(8) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub

阿倫 發表在 痞客邦 PIXNET 留言(0) 人氣()