p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Visual Basic 2008 Professionals (http://p2p.wrox.com/visual-basic-2008-professionals-359/)
-   -   Validate from textbox (http://p2p.wrox.com/visual-basic-2008-professionals/92469-validate-textbox.html)

marvin_ss March 16th, 2014 09:35 AM

Validate from textbox
hei, i'm new to this forum, i'm here to ask you about my problem in vb.net
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

mmorgan30 March 25th, 2014 01:18 AM

What do you mean by validate a text box on your notepad.

All times are GMT -4. The time now is 02:50 AM.

Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.