Advertisement
asril99

Untitled

Aug 15th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. Private Sub EmailTextBox_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles EmailTextBox.Validating
  2. Dim temp As String
  3. temp = EmailTextBox.Text
  4. Dim conditon As Boolean
  5. emailaddresscheck(temp)
  6. If emailaddresscheck(conditon) = False Then
  7. MessageBox.Show("Please enter your email address correctly", "Incorrect Email Entry")
  8. EmailTextBox.Text = ""
  9. EmailTextBox.BackColor = Color.Blue
  10. Else
  11. EmailTextBox.BackColor = Color.Green
  12. End If
  13.  
  14. End Sub
  15.  
  16.  
  17. Private Function emailaddresscheck(ByVal emailaddress As String) As Boolean
  18. Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
  19. Dim emailAddressMatch As Match = Regex.Match(emailaddress, pattern)
  20. If emailAddressMatch.Success Then
  21. emailaddresscheck = True
  22. Else
  23. emailaddresscheck = False
  24. End If
  25. End Function
  26.  
  27. Private Sub EmailTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EmailTextBox.TextChanged
  28. EmailTextBox.BackColor = Color.White
  29. Dim temp As String
  30. temp = EmailTextBox.Text
  31. Dim conditon As Boolean
  32. emailaddresscheck(temp)
  33. : If emailaddresscheck(conditon) = True Then
  34. MessageBox.Show("Please enter your email address correctly", "Incorrect Email Entry")
  35. EmailTextBox.Text = ""
  36. EmailTextBox.BackColor = Color.Yellow
  37. Else
  38. EmailTextBox.BackColor = Color.Green
  39. End If
  40. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement