16,717
社区成员
发帖
与我相关
我的任务
分享
''-------------------------------------------------
'' [処理名]:txtTime2_KeyUp
'' [機 能]:数字入力を判断する
'' [引 数]:なし
'' [返 値]:なし
'' [備 考]:なし
'' [作成者]:大連
'' [作成日]:08.11.19
''-------------------------------------------------
Private Sub txtTime2_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTime2.KeyUp
Dim str As String = ""
If (e.KeyValue > 47 And e.KeyValue < 58) Or (e.KeyValue > 95 And e.KeyValue < 106) Or (e.KeyValue = 8) Or (e.KeyValue = 45) Or (e.KeyValue = 46) Then
str = txtTime2.Text
Else
txtTime2.Text = str
txtTime2.Focus()
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
'Keyを判断する
If Char.IsNumber(e.KeyChar) OrElse Asc(e.KeyChar) = Keys.Back Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
this.textBox1.LostFocus += new EventHandler(TextBox1_LostFocus);
private void TextBox1_LostFocus(object sender, EventArgs e)
{
MessageBox.Show("11111");
//写你的字符判断逻辑
MessageBox.Show("11111");
//写你的查询逻辑 例如:
string txt = textBox1.Text.Trim();
try
{
int number = Int32.Parse(txt);
}
catch (System.Exception e)
{
MessageBox.Show("文本不是数字");
}
}
Private Sub textNo_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textNo.KeyUp
Dim str As String = ""
If (e.KeyValue > 47 And e.KeyValue < 58) Or (e.KeyValue > 95 And e.KeyValue < 106) Or (e.KeyValue = 8) Or (e.KeyValue = 45) Or (e.KeyValue = 46) Then
str = sender.Text
Else
sender.Text = str
sender.Focus()
End If
End Sub