Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class PersonalInfo
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- Form1.Show()
- Me.Close()
- End Sub
- Private Sub txtUser_TextChanged(sender As Object, e As EventArgs) Handles txtUser.TextChanged
- 'change the text of the label to inform the user
- 'test condition
- 'if true change to O and color green
- 'else change to X and color red
- lblMessage.Text = "Accepting username - Minimum 8 characters long"
- If txtUser.Text.Length < 8 Then
- lblUser.ForeColor = Color.Red
- lblUser.Text = "X"
- Else
- lblUser.ForeColor = Color.Green
- lblUser.Text = "O"
- lblMessage.Text = "Username Acceptable"
- End If
- End Sub
- Private Function checkPassword(ByVal passwordData As String) As Boolean
- Dim upper, lower, special, number As Boolean
- Dim asciiValue As Integer
- If passwordData.Length < 8 Then
- Return False
- End If
- For counter = 0 To passwordData.Length - 1
- asciiValue = Asc(passwordData(counter))
- Select Case asciiValue
- Case 65 To 90
- upper = True
- Case 97 To 122
- lower = True
- Case 48 To 57
- number = True
- Case 32 To 47, 58 To 64, 91 To 96, 123 To 126
- special = True
- End Select
- Next
- If upper = True And lower = True And special = True And number = True Then
- Return True
- Else
- Return False
- End If
- End Function
- Private Sub PersonalInfo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- txtUser.Focus()
- End Sub
- Private Function checkPassword1(ByVal passwordText As String) As Boolean
- Dim asciiValue As Integer
- Dim upper, lower, special, number As Boolean
- If passwordText.Length < 8 Then
- Return False
- End If
- For counter = 0 To passwordText.Length - 1
- asciiValue = Asc(passwordText(counter))
- Select Case asciiValue
- Case 65 To 90
- upper = True
- Case 97 To 122
- lower = True
- Case 48 To 57
- number = True
- Case 32 To 47, 58 To 64, 91 To 96, 123 To 126
- special = True
- End Select
- Next
- If upper = True And lower = True And special = True And number = True Then
- Return True
- Else
- Return False
- End If
- End Function
- Private Sub txtPass_TextChanged(sender As Object, e As EventArgs) Handles txtPass.TextChanged
- 'change the text of the label to inform the user
- 'test condition
- 'if true change to O and color green
- 'else change to X and color red
- lblMessage.Text = "Accepting password - Min 8 char/upper/lower/special char"
- If checkPassword(txtPass.Text) = False Then
- lblPass.ForeColor = Color.Red
- lblPass.Text = "X"
- Else
- lblPass.ForeColor = Color.Green
- lblPass.Text = "O"
- lblMessage.Text = "Password Acceptable"
- End If
- End Sub
- Private Sub txtReEnter_TextChanged(sender As Object, e As EventArgs) Handles txtReEnter.TextChanged
- 'change the text of the label to inform the user
- 'test condition
- 'if true change to O and color green
- 'else change to X and color red
- lblMessage.Text = "ReEnter Password"
- If txtPass.Text <> txtReEnter.Text Then
- lblReenter.ForeColor = Color.Red
- lblReenter.Text = "X"
- Else
- lblReenter.ForeColor = Color.Green
- lblReenter.Text = "O"
- lblMessage.Text = "Password Match"
- End If
- End Sub
- Private Sub txtPh_TextChanged(sender As Object, e As EventArgs) Handles txtPh.TextChanged
- lblMessage.Text = "Accepting Phone number"
- If checkPhone(txtPh.Text) = False Then
- lblPhone.ForeColor = Color.Red
- lblPhone.Text = "X"
- Else
- txtPh.Text = txtPh.Text.Substring(0, 3) & "." _
- & txtPh.Text.Substring(3, 3) & "." & txtPh.Text.Substring(6)
- lblPhone.ForeColor = Color.Green
- lblPhone.Text = "O"
- lblMessage.Text = "Phone number accepted"
- txtEmail.Focus()
- End If
- End Sub
- Private Function checkPhone(ByVal value As String) As Boolean
- If Not IsNumeric(value) Or value.Length <> 10 Then
- Return False
- Else
- Return True
- End If
- End Function
- Private Function checkEmail(ByVal value As String) As Boolean
- Try
- If value.IndexOf("@") = -1 Then
- Return False
- ElseIf value.IndexOf(".") = -1 Then
- Return False
- ElseIf value.IndexOf(".edu") = -1 Then
- Return False
- Else
- Return True
- End If
- Catch ex As Exception
- Return False
- End Try
- End Function
- Private Sub txtEmail_TextChanged(sender As Object, e As EventArgs) Handles txtEmail.TextChanged
- lblMessage.Text = "Accepting email Address now"
- If checkEmail(txtEmail.Text) = False Then
- lblEmail.ForeColor = Color.Red
- lblEmail.Text = "X"
- Else
- lblEmail.ForeColor = Color.Green
- lblEmail.Text = "O"
- lblMessage.Text = "email accepted"
- End If
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- MessageBox.Show("Following information will be registered:" & vbCrLf &
- vbCrLf & "UserName: " & txtUser.Text & vbCrLf &
- vbCrLf & "Password: " & txtPass.Text & vbCrLf &
- vbCrLf & "PhoneNo: " & txtPh.Text & vbCrLf &
- vbCrLf & "Email: " & txtEmail.Text)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement