Visual Basic Valid Email Checker
Submitted by Yorkiebar on Wednesday, September 18, 2013 - 08:59.
Introduction:
This tutorial is on how to create a simple email checker in Visual Basic.
Steps of Creation:
Step 1:
First we will need a new form with a textbox1 for the email file path, a file full of emails ready for checking, a textbox2 to define the path to save the valid emails and a button to start checking the emails.
We will also require the following imports...
Step 2:
Next lets get all the emails from our list...
Step 3:
Next lets check each email for the @ and . signs...
Step 4:
Finally we need to output the valid emails to our save path (textbox2)
Project Complete!
That's it! Below is the full source code and download to the project files:
- Imports System.IO
- Dim emails As New List(Of String)
- Dim working As New List(Of String)
- Using sr As New StreamReader(TextBox1.Text)
- While sr.Peek <> -1
- emails.Add(sr.ReadLine())
- End While
- End Using
- For Each em As String In emails
- If (em.Contains("@") And em.Contains(".")) Then
- working.add(em)
- End If
- Next
- Using sw As New StreamWriter(TextBox2.Text)
- For Each emm As String In working
- sw.WriteLine(emm)
- Next
- End Using
- Imports System.IO
- Public Class Form1
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- 'Dim fo As New OpenFileDialog
- 'fo.RestoreDirectory = True
- 'fo.Filter = "txt files (*.txt)|*.txt"
- 'fo.FilterIndex = 1
- 'fo.ShowDialog()
- Dim emails As New List(Of String)
- Dim working As New List(Of String)
- Using sr As New StreamReader(TextBox1.Text)
- While sr.Peek <> -1
- emails.Add(sr.ReadLine())
- End While
- End Using
- For Each em As String In emails
- If (em.Contains("@") And em.Contains(".")) Then
- working.add(em)
- End If
- Next
- Using sw As New StreamWriter(TextBox2.Text)
- For Each emm As String In working
- sw.WriteLine(emm)
- Next
- End Using
- End Sub
- End Class
Add new comment
- 34 views