Friday 30 September 2016

VB6 Project Validation





Click Here to Download Project


Option Explicit

Private Sub cmdadd_Click()
Module1.return_count ("select * from employee")
rs.MoveLast
txteno.Text = rs.Fields(0).Value + 1
txteno.Enabled = False
cmdadd.Enabled = False
cmdsave.Enabled = True

End Sub

Private Sub cmdsave_Click()

If txteno.Text = "" Or txtename.Text = "" Or txtEmob.Text = "" Or txtEaddr.Text = "" Or txtmail.Text = "" Or txtsal.Text = "" Then
MsgBox "Fill All the Fields", vbExclamation + vbOKOnly, "Incomplete Fields"
txtename.SetFocus
Else
Module1.return_count ("insert into employee values(" & CInt(txteno.Text) & ",'" & txtename.Text & "','" & txtmail.Text & "','" & txtEmob.Text & "','" & txtEaddr.Text & "'," & CCur(txtsal.Text) & ")")
MsgBox ("Employee Details save successfuly.... ")
cmdsave.Enabled = False
cmdadd.Enabled = True
Call clearText
End If
End Sub
Private Sub clearText()
 txteno.Text = ""
 txtename.Text = ""
 txtEmob.Text = ""
 txtEaddr.Text = ""
 txtmail.Text = ""
 txtsal.Text = ""
End Sub
Private Sub Form_Load()
Me.Height = 8895
Me.Width = 15405
End Sub


Private Sub txtEmob_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
Else
MsgBox "Enter Numbers only", vbExclamation + vbOKCancel, "Invalid input"
KeyAscii = 0
txtEmob.SetFocus
End If

End Sub

Private Sub txtEmob_LostFocus()
If Left(txtEmob.Text, 1) > 6 And Len(txtEmob.Text) = 10 Then
txtEmob.BackColor = vbWhite
Else
MsgBox "Invalid Mobile ", vbExclamation + vbOKCancel, "Invalid input"
txtEmob.BackColor = vbRed
End If

End Sub

Private Sub txtename_KeyPress(KeyAscii As Integer)
If KeyAscii >= 65 And KeyAscii <= 91 Or KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii = 8 Or KeyAscii = 32 Then
Else
MsgBox "Enter Alphabets only", vbExclamation + vbOKCancel, "Invalid input"
KeyAscii = 0
txtename.SetFocus
End If
End Sub



Private Sub txtmail_LostFocus()
Dim flag As Boolean
flag = False
Dim myRegExp As RegExp
Dim myMatches As MatchCollection
Dim myMatch As Match
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$"
Set myMatches = myRegExp.Execute(txtmail.Text)
For Each myMatch In myMatches
flag = True
Next
If flag = False Then
MsgBox ("Invalid Email")
txtmail.BackColor = vbRed
txtmail.SetFocus
Else
txtmail.BackColor = vbWhite

End If

End Sub