Ignore key code : Key Event « Event « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Event » Key Event 
11.6.4.Ignore key code
Ignore key code
Imports System.Windows.Forms

public class TextBoxValidating
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
   Friend WithEvents Label1 As System.Windows.Forms.Label
   Friend WithEvents txtInput As System.Windows.Forms.TextBox
   Friend WithEvents Label2 As System.Windows.Forms.Label
   Friend WithEvents Label3 As System.Windows.Forms.Label
   Friend WithEvents lblTrue As System.Windows.Forms.Label
   Friend WithEvents lblCheck As System.Windows.Forms.Label
   Friend WithEvents lblResults As System.Windows.Forms.Label
   Friend WithEvents btnClear As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.txtInput = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.lblTrue = New System.Windows.Forms.Label()
Me.lblCheck = New System.Windows.Forms.Label()
Me.lblResults = New System.Windows.Forms.Label()
Me.btnClear = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Tahoma"14.25!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(4816)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(17623)
Me.Label1.TabIndex = 0
Me.Label1.Text = "ISBN Validation"
'
'txtInput
'
Me.txtInput.Location = New System.Drawing.Point(7264)
Me.txtInput.Name = "txtInput"
Me.txtInput.TabIndex = 1
Me.txtInput.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24104)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(8023)
Me.Label2.TabIndex = 2
Me.Label2.Text = "True Number:"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(32152)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(7223)
Me.Label3.TabIndex = 3
Me.Label3.Text = "Check Digit:"
'
'lblTrue
'
Me.lblTrue.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblTrue.Location = New System.Drawing.Point(112104)
Me.lblTrue.Name = "lblTrue"
Me.lblTrue.TabIndex = 4
'
'lblCheck
'
Me.lblCheck.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblCheck.Location = New System.Drawing.Point(112152)
Me.lblCheck.Name = "lblCheck"
Me.lblCheck.TabIndex = 5
'
'lblResults
'
Me.lblResults.Location = New System.Drawing.Point(56192)
Me.lblResults.Name = "lblResults"
Me.lblResults.Size = New System.Drawing.Size(15224)
Me.lblResults.TabIndex = 6
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(88240)
Me.btnClear.Name = "btnClear"
Me.btnClear.TabIndex = 7
Me.btnClear.Text = "Clear"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(513)
Me.ClientSize = New System.Drawing.Size(264293)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnClear, Me.lblResults, Me.lblCheck, Me.lblTrue, Me.Label3, Me.Label2, Me.txtInput, Me.Label1})
Me.Name = "Form1"
Me.Text = "ISBN Validation"
Me.ResumeLayout(False)

    End Sub

#End Region

 
   Private Sub IsbnValidation(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgsHandles txtInput.Validating

         Console.WriteLine("validating")
   End Sub

   Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles btnClear.Click
      txtInput.Text = ""
      lblResults.Text = ""
      lblTrue.Text = ""
      lblCheck.Text = ""
   End Sub

   Private Sub txtInput_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgsHandles txtInput.KeyPress
      Dim keyChar As Char
      keyChar = e.KeyChar
      
      ' Suppress any keys except digits,X,x,hyphen (45),Backspace (8),or Enter (13)
      If ((Not Char.IsDigit(keyChar)) _
         And (AscW(keyChar<> 8_
         And (AscW(keyChar<> 13_
         And (keyChar <> "X"c_
         And (keyChar <> "x"c_
         And (AscW(keyChar<> 45)) Then
         '  Do not display the keystroke
         e.Handled = True
      End If
   End Sub
End Class
11.6.Key Event
11.6.1.Check Key Code: F5Check Key Code: F5
11.6.2.Displaying information about a user-pressed keyDisplaying information about a user-pressed key
11.6.3.Determine whether user pressed Enter keyDetermine whether user pressed Enter key
11.6.4.Ignore key codeIgnore key code
11.6.5.Key event summaryKey event summary
11.6.6.Control KeyControl Key
11.6.7.Shift KeyShift Key
11.6.8.Check Key Code rangeCheck Key Code range
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.