.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
IP地址输入控件 V1.0.1.1版(FOR Win Form)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

核心代码:

 '只允许输入数字、"."
    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
            Select Case tx1.Name
                Case "txtField3"
                    If txtField3.Text = "" Then
                        txtField2.Focus()
                    End If
                Case "txtField2"
                    If txtField2.Text = "" Then
                        txtField1.Focus()
                    End If
                Case "txtField1"
                    If txtField1.Text = "" Then
                        txtField0.Focus()
                    End If
            End Select
        End If
    End Sub

当运行时:

当出现错误时:
 




相关文章

相关软件