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

VB.NET中讓Textbox只能輸入數字

2022-06-13   來源: .NET編程 

  

  Public Class Form
    Inherits SystemWindowsFormsForm

  #Region Windows 窗體設計器生成的代碼

  Public Sub New()
        MyBaseNew()

  該調用是 Windows 窗體設計器所必需的
        InitializeComponent()

  在 InitializeComponent() 調用之後添加任何初始化

  End Sub

  窗體重寫 dispose 以清理組件列表
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                componentsDispose()
            End If
        End If
        MyBaseDispose(disposing)
    End Sub

  Windows 窗體設計器所必需的
    Private components As SystemComponentModelIContainer

  注意: 以下過程是 Windows 窗體設計器所必需的
    可以使用 Windows 窗體設計器修改此過程
    不要使用代碼編輯器修改它
    Friend WithEvents TextBox As SystemWindowsFormsTextBox
    Private Sub InitializeComponent()
        MeTextBox = New SystemWindowsFormsTextBox
        MeSuspendLayout()
       
        TextBox
       
        MeTextBoxLocation = New SystemDrawingPoint( )
        MeTextBoxName = TextBox
        MeTextBoxTabIndex =
        MeTextBoxText =
       
        Form
       
        MeAutoScaleBaseSize = New SystemDrawingSize( )
        MeClientSize = New SystemDrawingSize( )
        MeControlsAdd(MeTextBox)
        MeName = Form
        MeText = Form
        MeResumeLayout(False)

  End Sub

  #End Region
    Dim str As String =

  Private Sub TextBox_KeyUp(ByVal sender As Object ByVal e As SystemWindowsFormsKeyEventArgs) Handles TextBoxKeyUp
        If (eKeyValue > And eKeyValue < ) Or (eKeyValue > And eKeyValue < ) Or (eKeyValue = ) Or (eKeyValue = ) Or (eKeyValue = ) Then
            str = TextBoxText
        Else
            TextBoxText = str
            TextBoxFocus()
        End If
    End Sub
End Class


From:http://tw.wingwit.com/Article/program/net/201311/13841.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.