Data Entry Validation Techniques - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Data Entry Validation Techniques

Description:

Data Entry Validation Techniques & Operations on Strings ... Inserting Characters within a String. Dim phone as string = '1234567890' Phone = phone.insert(0, ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 19
Provided by: semin1
Category:

less

Transcript and Presenter's Notes

Title: Data Entry Validation Techniques


1
Data Entry Validation Techniques Operations on
Strings
2
Data EntryValidation on the keyboard level
  • InStr function
  • ASCII coding scheme
  • Chr, Asc functions
  • KeyPress event
  • Mid statement and function

3
InStr function
  • to decide if one string is in another string
  • InStr(string1, string2)
  • string1 is the string being searched, string2 is
    the
  • string being sought
  • if string2 is not in string1, InStr returns 0
  • if string2 is in string1, InStr returns the
    position at
  • which the match is found

4
InStr Example
InStr (abcvt, v) value 4 is returned
InStr(abcvt, s) value 0 is returned
5
ASCII Code
  • American Standard Code for Information
    Interchange

ASCII Character ASCII Character 8
back space 64 _at_ 48
0 65 A 49
1 66 B 50
2 67 C 61
97 a 62
gt 98 b .
6
Asc function
  • Returns the character code corresponding to the
    first
  • letter in a string

MyNumber Asc("A") ' Returns 65. MyNumber
Asc("a") ' Returns 97. MyNumber Asc("Apple") '
Returns 65.
7
Chr function
  • Chr function returns the character associated
    with the
  • specified character code

MyChar Chr(65) ' Returns A. MyChar Chr(97) '
Returns a. MyChar Chr(62) ' Returns gt. MyChar
Chr(37) ' Returns .
8
(No Transcript)
9
KeyPress event
Private Sub Text1_KeyPress(ByVal Sender As
System.Object, ByVal e As KeyPressEventArgs)
Handles Text1.KeyPress Dim validstring
As String validstring "0123456789"
'to check if the key pressed is a member of
validstring If InStr(validstring,
e.KeyChar.ToString) 0 Then
e.Handled True 'input ignored End
If End Sub
Character of the key pressed
10
Private Sub Text2_KeyPress(ByVal Sender As
System.Object, ByVal e As KeyPressEventArgs)
Handles Text2.KeyPress Dim validstring
As String validstring "0123456789.-"
'to check if the key pressed is a member of
validstring If InStr(validstring,
e.KeyChar.ToString) 0 Then
e.Handled True 'input ignored End
If End Sub
11
Private Sub Text3_KeyPress(ByVal Sender As
System.Object, ByVal e As KeyPressEventArgs)
Handles Text3.KeyPress Dim i As Short
i Asc(e.KeyChar) Dim validstring
As String If i ltgt 8 Then 'enable
backspace key validstring
"0123456789.-" 'to check if the key
pressed is a member of validstring If
InStr(validstring, e.KeyChar.ToString) 0 Then
e.Handled True 'input
ignored End If End If End
Sub
12
Private Sub Text5_KeyPress(ByVal Sender As
System.Object, ByVal e As KeyPressEventArgs)
Handles Text5.KeyPress 'change the
selected text into uppercase
Text5.SelectedText e.KeyChar.ToString.ToUpper
e.Handled True End Sub
13
Data Entry Validation Using the Leave Event
Private Sub TextBox1_Leave(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
TextBox1.Leave If Not IsDate(TextBox1.Tex
t) Then MessageBox.Show("Please enter
a date") TextBox1.Text ""
TextBox1.Focus() End If End Sub
14
Replacing Characters in Strings
Dim phone as string 614-292-2345 phone
phone.replace(-, ) 6142922345
Dim aWord as string latter aWord
aWord.replace(t, d) ladder
Replacing all occurrences
15
Mid Statement
Replace a specified number of characters in a
string.
Dim myString as string myString The dog
jumps Mid(myString, 5, 3) fox myString
The fox jumps Mid(myString, 5) cat
mySring The cat jumps
Index is one based.
16
Mid Function
Returns a string containing a specified number of
characters from a string.
Dim myString, firstWord as string myString
Mid function demo firstWord mid(myString, 1,
3) returns Mid firstWord mid(myString,
5) returns function demo
Index is one based.
17
Inserting Characters within a String
Dim phone as string 1234567890 Phone
phone.insert(0, () Phone phone.insert(4,
)) Phone phone.insert(8, -) Result
(123)456-7890
Index is zero based.
18
How to get the number into the display?
Write a Comment
User Comments (0)
About PowerShow.com