Number-Only Text Box : TextBox Special « GUI « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » GUI » TextBox SpecialScreenshots 
Number-Only Text Box
  
Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form
    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub

    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.TextBox1 = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        Me.TextBox1.Location = New System.Drawing.Point(6464)
        Me.TextBox1.Size = New System.Drawing.Size(20820)
        Me.TextBox1.Text = ""
        '
        Me.Label1.Location = New System.Drawing.Point(816)
        Me.Label1.Size = New System.Drawing.Size(32823)
        Me.Label1.Text = "Numbers, a colon, dash and space:"
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(344149)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1, Me.TextBox1})
        Me.Text = "Creating your Own Number-Only Text Box"
        Me.ResumeLayout(False)
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgsHandles TextBox1.KeyPress
        Dim strAllowableChars As String
        strAllowableChars = "0123456789-: "
        If InStr(strAllowableChars, e.KeyChar.ToStringThen
            e.Handled = True
        End If
    End Sub
End Class

   
    
  
Related examples in the same category
1.Number only TextBoxNumber only TextBox
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.