Advertisement
Guest User

Untitled

a guest
Apr 30th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. Public Class PersonalInfo
  2. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  3. Form1.Show()
  4. Me.Close()
  5. End Sub
  6.  
  7. Private Sub txtUser_TextChanged(sender As Object, e As EventArgs) Handles txtUser.TextChanged
  8. 'change the text of the label to inform the user
  9. 'test condition
  10. 'if true change to O and color green
  11. 'else change to X and color red
  12.  
  13. lblMessage.Text = "Accepting username - Minimum 8 characters long"
  14. If txtUser.Text.Length < 8 Then
  15. lblUser.ForeColor = Color.Red
  16. lblUser.Text = "X"
  17. Else
  18. lblUser.ForeColor = Color.Green
  19. lblUser.Text = "O"
  20. lblMessage.Text = "Username Acceptable"
  21. End If
  22. End Sub
  23. Private Function checkPassword(ByVal passwordData As String) As Boolean
  24. Dim upper, lower, special, number As Boolean
  25. Dim asciiValue As Integer
  26.  
  27. If passwordData.Length < 8 Then
  28. Return False
  29. End If
  30.  
  31. For counter = 0 To passwordData.Length - 1
  32. asciiValue = Asc(passwordData(counter))
  33. Select Case asciiValue
  34. Case 65 To 90
  35. upper = True
  36. Case 97 To 122
  37. lower = True
  38. Case 48 To 57
  39. number = True
  40. Case 32 To 47, 58 To 64, 91 To 96, 123 To 126
  41. special = True
  42. End Select
  43. Next
  44.  
  45. If upper = True And lower = True And special = True And number = True Then
  46. Return True
  47. Else
  48. Return False
  49. End If
  50.  
  51. End Function
  52.  
  53. Private Sub PersonalInfo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  54. txtUser.Focus()
  55. End Sub
  56. Private Function checkPassword1(ByVal passwordText As String) As Boolean
  57. Dim asciiValue As Integer
  58. Dim upper, lower, special, number As Boolean
  59.  
  60. If passwordText.Length < 8 Then
  61. Return False
  62. End If
  63.  
  64. For counter = 0 To passwordText.Length - 1
  65. asciiValue = Asc(passwordText(counter))
  66. Select Case asciiValue
  67. Case 65 To 90
  68. upper = True
  69. Case 97 To 122
  70. lower = True
  71. Case 48 To 57
  72. number = True
  73. Case 32 To 47, 58 To 64, 91 To 96, 123 To 126
  74. special = True
  75. End Select
  76. Next
  77. If upper = True And lower = True And special = True And number = True Then
  78. Return True
  79. Else
  80. Return False
  81. End If
  82. End Function
  83.  
  84.  
  85. Private Sub txtPass_TextChanged(sender As Object, e As EventArgs) Handles txtPass.TextChanged
  86. 'change the text of the label to inform the user
  87. 'test condition
  88. 'if true change to O and color green
  89. 'else change to X and color red
  90. lblMessage.Text = "Accepting password - Min 8 char/upper/lower/special char"
  91. If checkPassword(txtPass.Text) = False Then
  92. lblPass.ForeColor = Color.Red
  93. lblPass.Text = "X"
  94. Else
  95. lblPass.ForeColor = Color.Green
  96. lblPass.Text = "O"
  97. lblMessage.Text = "Password Acceptable"
  98. End If
  99. End Sub
  100.  
  101. Private Sub txtReEnter_TextChanged(sender As Object, e As EventArgs) Handles txtReEnter.TextChanged
  102. 'change the text of the label to inform the user
  103. 'test condition
  104. 'if true change to O and color green
  105. 'else change to X and color red
  106.  
  107. lblMessage.Text = "ReEnter Password"
  108. If txtPass.Text <> txtReEnter.Text Then
  109. lblReenter.ForeColor = Color.Red
  110. lblReenter.Text = "X"
  111. Else
  112. lblReenter.ForeColor = Color.Green
  113. lblReenter.Text = "O"
  114. lblMessage.Text = "Password Match"
  115.  
  116. End If
  117. End Sub
  118.  
  119. Private Sub txtPh_TextChanged(sender As Object, e As EventArgs) Handles txtPh.TextChanged
  120. lblMessage.Text = "Accepting Phone number"
  121. If checkPhone(txtPh.Text) = False Then
  122. lblPhone.ForeColor = Color.Red
  123. lblPhone.Text = "X"
  124. Else
  125. txtPh.Text = txtPh.Text.Substring(0, 3) & "." _
  126. & txtPh.Text.Substring(3, 3) & "." & txtPh.Text.Substring(6)
  127. lblPhone.ForeColor = Color.Green
  128. lblPhone.Text = "O"
  129. lblMessage.Text = "Phone number accepted"
  130. txtEmail.Focus()
  131. End If
  132. End Sub
  133.  
  134. Private Function checkPhone(ByVal value As String) As Boolean
  135. If Not IsNumeric(value) Or value.Length <> 10 Then
  136. Return False
  137. Else
  138. Return True
  139. End If
  140. End Function
  141. Private Function checkEmail(ByVal value As String) As Boolean
  142. Try
  143. If value.IndexOf("@") = -1 Then
  144. Return False
  145. ElseIf value.IndexOf(".") = -1 Then
  146. Return False
  147. ElseIf value.IndexOf(".edu") = -1 Then
  148. Return False
  149. Else
  150. Return True
  151. End If
  152. Catch ex As Exception
  153. Return False
  154. End Try
  155. End Function
  156. Private Sub txtEmail_TextChanged(sender As Object, e As EventArgs) Handles txtEmail.TextChanged
  157. lblMessage.Text = "Accepting email Address now"
  158. If checkEmail(txtEmail.Text) = False Then
  159. lblEmail.ForeColor = Color.Red
  160. lblEmail.Text = "X"
  161. Else
  162. lblEmail.ForeColor = Color.Green
  163. lblEmail.Text = "O"
  164. lblMessage.Text = "email accepted"
  165. End If
  166. End Sub
  167.  
  168. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  169. MessageBox.Show("Following information will be registered:" & vbCrLf &
  170. vbCrLf & "UserName: " & txtUser.Text & vbCrLf &
  171. vbCrLf & "Password: " & txtPass.Text & vbCrLf &
  172. vbCrLf & "PhoneNo: " & txtPh.Text & vbCrLf &
  173. vbCrLf & "Email: " & txtEmail.Text)
  174. End Sub
  175. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement