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.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.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
w_w_w_.j__a___v_a___2_s___.c_o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.