View Single Post
  #1 (permalink)  
Old March 16th, 2014, 09:35 AM
marvin_ss marvin_ss is offline
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validate from textbox

hei, i'm new to this forum, i'm here to ask you about my problem in
how can i validate an user input from textbox, but you have to validate it on your notepad, so if that user input don't have in notepad, it won't validate, but if it has then it validate, this is my code, but in there if i input from textbox it save to the notepad not validate

Imports System.IO

Public Class TryCatch
Dim sFileName As String = Application.StartupPath & "\email.txt"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myFileStream As New System.IO.FileStream(sFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
Dim myReader As New System.IO.StreamReader(myFileStream)
Dim sFileContents As String = myReader.ReadToEnd()
TextBox1.Text = sFileContents
Catch ex As Exception
End Try
End Sub

Function ValidateEmail(ByVal email As String) As Boolean
Dim emailRegex As _
New System.Text.RegularExpressions.Regex( _
Dim emailMatch As _
System.Text.RegularExpressions.Match = emailRegex.Match(email)
Return emailMatch.Success
End Function

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
Dim sFileName As String = OpenFileDialog1.FileName.ToString()
Dim data() As String
Dim dataPerLine As String = Nothing
Dim ItemList As ListViewItem
Dim MyFileStream As System.IO.FileStream
MyFileStream = New System.IO.FileStream(sFileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)

If MyFileStream.CanRead = True Then
Dim MyReader As New System.IO.StreamReader(MyFileStream)
While (Not MyReader.EndOfStream)
dataPerLine = MyReader.ReadLine()
data = dataPerLine.Split(New Char() {Chr(9)})
ItemList = New ListViewItem(data)
End While
End If
End Sub
End Class
Reply With Quote