最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
IP地址输入控件 V1.0.1.1版(FOR Win Form)
时间:2022-07-02 12:01:42 编辑:袖梨 来源:一聚教程网
核心代码:
'只允许输入数字、"."
Private Sub txtField_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtField0.KeyPress, txtField1.KeyPress, txtField2.KeyPress, txtField3.KeyPress
If e.KeyChar = "." Then
Dim tx As TextBox = CType(sender, TextBox)
'最后的文本框不可以输入"."
'在其它文本框输入".",相当于输入"Tab"键,即光标到下一文本框
If tx.Text = "" Or tx.SelectedText <> "" Then
e.Handled = True
End If
If tx.Name <> "txtField3" Then
SendKeys.Send("{TAB}")
Else
'最后的文本框不可以输入"."
e.Handled = True
End If
ElseIf (Not IsNumeric(e.KeyChar)) And e.KeyChar <> ControlChars.Back Then
e.Handled = True
Else
Dim tx As TextBox = CType(sender, TextBox)
If (Len(tx.Text) = 2 And e.KeyChar <> ControlChars.Back And tx.SelectedText.Length = 0) Then
If tx.Name <> "txtField3" Then
SendKeys.Send("{TAB}")
End If
End If
End If
'控制ControlChars.Back退格键
Dim tx1 As TextBox = CType(sender, TextBox)
If (Len(tx1.Text) = 0 And e.KeyChar = ControlChars.Back) Then
'只允许输入数字、"."
Private Sub txtField_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtField0.KeyPress, txtField1.KeyPress, txtField2.KeyPress, txtField3.KeyPress
If e.KeyChar = "." Then
Dim tx As TextBox = CType(sender, TextBox)
'最后的文本框不可以输入"."
'在其它文本框输入".",相当于输入"Tab"键,即光标到下一文本框
If tx.Text = "" Or tx.SelectedText <> "" Then
e.Handled = True
End If
If tx.Name <> "txtField3" Then
SendKeys.Send("{TAB}")
Else
'最后的文本框不可以输入"."
e.Handled = True
End If
ElseIf (Not IsNumeric(e.KeyChar)) And e.KeyChar <> ControlChars.Back Then
e.Handled = True
Else
Dim tx As TextBox = CType(sender, TextBox)
If (Len(tx.Text) = 2 And e.KeyChar <> ControlChars.Back And tx.SelectedText.Length = 0) Then
If tx.Name <> "txtField3" Then
SendKeys.Send("{TAB}")
End If
End If
End If
'控制ControlChars.Back退格键
Dim tx1 As TextBox = CType(sender, TextBox)
If (Len(tx1.Text) = 0 And e.KeyChar = ControlChars.Back) Then
相关文章
- 蚂蚁庄园今日课堂答题2024年11月14日 11-16
- 《尼尔:机械纪元》武器黑之倨傲属性及特殊能力介绍 11-15
- 《尼尔:机械纪元》机械生命体的枪获得方法介绍 11-15
- 《尼尔:机械纪元》武器机械生命体的枪属性及特殊能力介绍 11-15
- 《尼尔:机械纪元》天使之圣翼获得方法介绍 11-15
- 《尼尔:机械纪元》武器天使之圣翼属性及特殊能力介绍 11-15