by Afika Mabutyana (Afro) (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Sun 27th September 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Validates User Input(student name,student number And E-mail Address), then it saves the data on a text file
API Declarations
Dim valid As Boolean
Dim details As String = "C:\Documents and Settings\client\My Documents\details.txt"
Dim objWriter As New System.IO.StreamWriter(details, True)
'It made use of Functions to validate input
'It displays output on a text file (My Documents\Details)
'Proudly created By A.Mabutyana (Afro)
'Walter Sisulu University (Development Software 2 Student)
Private Sub btnvalidate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvalidate.Click
Sname = CStr(txtname.Text)
If validname(Sname) Then
objWriter.WriteLine(txtname.Text)
Else
MsgBox("Invalid Name", MsgBoxStyle.Exclamation, "Error")
txtname.Clear()
txtname.Focus()
End If
Snumber = CStr(txtnumber.Text)
If validnumber(Snumber) Then
objWriter.WriteLine(txtnumber.Text)
Else
MsgBox("Invalid Number", MsgBoxStyle.Exclamation, "Error")
txtnumber.Clear()
txtnumber.Focus()
End If
Eaddress = CStr(txtaddress.Text)
If validemail(Eaddress) Then
objWriter.WriteLine(txtaddress.Text)
Else
MsgBox("Invalid E-mail", MsgBoxStyle.Exclamation, "Error")
txtaddress.Clear()
txtaddress.Focus()
End If
objWriter.Close()
End Sub
Function validname(ByVal name As String) As Boolean
Dim ans As Boolean
For i As Integer = 0 To name.Length - 1
Select Case name.Substring(i, 1)
Case "A" To "Z"
Case "a" To "z"
ans = True
Case Else
ans = False
End Select
Next
Return ans
End Function
Function validnumber(ByVal number As String) As Boolean
If IsNumeric(Snumber) And Snumber.Length = 9 Then
valid = True
Else
valid = False
End If
Return valid
End Function
Function validemail(ByVal mail As String) As Boolean
If mail.IndexOf("@") >= 0 And mail.IndexOf(".") >= 0 Then
valid = True
Else
valid = False
End If
Return valid
End Function
No comments have been posted about Validates User Input(student name,student number And E-mail Address), then it saves the data on a t. Why not be the first to post a comment about Validates User Input(student name,student number And E-mail Address), then it saves the data on a t.