Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. Public Class Form1
  2. Private Sub txtUsername_TextChanged(sender As Object, e As EventArgs) Handles txtUsername.TextChanged
  3. If txtUsername.Text.Length < 8 Then
  4. lblUsername.ForeColor = Color.Red
  5. lblUsername.Text = "X"
  6. Else
  7. lblUsername.ForeColor = Color.Green
  8. lblUsername.Text = "O"
  9. End If
  10.  
  11. End Sub
  12.  
  13. Private Sub txtPassword_TextChanged(sender As Object, e As EventArgs) Handles txtPassword.TextChanged
  14. Dim rawPassword As String
  15. Dim upper, lower, eight, special, number As Boolean
  16. upper = False : lower = False : eight = False : special = False : number = False
  17. Dim ascValue As Integer
  18.  
  19. rawPassword = txtPassword.Text
  20.  
  21. For counter = 0 To rawPassword.Length - 1
  22. ascvalue = Asc(rawPassword(counter))
  23. Select Case ascValue
  24. Case 65 To 90
  25. upper = True
  26. Case 97 To 122
  27. lower = True
  28. Case 48 To 57
  29. number = True
  30. Case 32 To 47, 58 To 64, 91 To 96, 123 To 126
  31. special = True
  32. End Select
  33. Next
  34.  
  35. If rawPassword.Length >= 8 Then
  36. eight = True
  37. End If
  38.  
  39. If upper = True And lower = True And eight = True And special = True And number = True And special = True Then
  40. lblPassword.ForeColor = Color.Green
  41. lblPassword.Text = "O"
  42. Else
  43. lblPassword.ForeColor = Color.Red
  44. lblPassword.Text = "X"
  45. End If
  46. End Sub
  47.  
  48. Private Sub txtReenter_TextChanged(sender As Object, e As EventArgs) Handles txtReenter.TextChanged
  49. If txtReenter.Text = txtPassword.Text Then
  50. lblReenter.ForeColor = Color.Green
  51. lblReenter.Text = "O"
  52. Else
  53. lblReenter.ForeColor = Color.Red
  54. lblReenter.Text = "X"
  55. End If
  56. End Sub
  57.  
  58. Private Sub txtPhoneNo_TextChanged(sender As Object, e As EventArgs) Handles txtPhoneNo.TextChanged
  59. Dim formatString As String
  60.  
  61. If txtPhoneNo.Text.Length <> 10 Or Not (IsNumeric(txtPhoneNo.Text)) Then
  62. lblPhoneNo.Text = "X"
  63. lblPhoneNo.ForeColor = Color.Red
  64. Else
  65. lblPhoneNo.Text = "O"
  66. lblPhoneNo.ForeColor = Color.Green
  67. End If
  68.  
  69. formatString = txtPhoneNo.Text.Substring(0, 3) & "-" &
  70. txtPhoneNo.Text.Substring(3, 3) & "-" & txtPhoneNo.Text.Substring(6, 4)
  71. txtPhoneNo.Text = formatString
  72.  
  73. lblPhoneNo.Text = "O"
  74. lblPhoneNo.ForeColor = Color.Green
  75. End Sub
  76. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement