Rem ******************************************************************** Rem * Rem * Delete Do-Not-Call 1.0 by PhilVaz Rem * Rem * Delete Do-Not-Call Numbers from a List of Phone Numbers Rem * given a plain text file of Do Not Call numbers Rem * Area codes valid 813 727 352 863 941 Rem * Rem ******************************************************************** Rem ************************************************** Rem * Deletes Do-Not-Call from Input Rem ************************************************** Private Sub cmdDeleteDoNotCall_Click() Dim InFile1 As String, InFile2 As String, OutFile As String, InLine As String Dim Phone1 As String, Phone2 As String, Area1 As String Dim I As Long, TotalLines As Long, TotalDeletes As Long Dim OkayToCall As Boolean InFile1 = lblInputFile1 InFile2 = lblInputFile2 OutFile = lblOutputFile1 If InFile1 = "" Or InFile2 = "" Or OutFile = "" Or InFile1 = InFile2 Or InFile1 = OutFile Or InFile2 = OutFile Then MsgBox ("Sorry, file names missing for Input or Output, or file names conflict") Else Rem * Read entire file to set progress bar to max lblStatus = "STATUS: Determining Size of Input File...." DeleteDoNotCall.Refresh TotalLines = 0 Open InFile1 For Input As #1 Do While Not EOF(1) Line Input #1, InLine TotalLines = TotalLines + 1 Loop Close #1 ProgressBar1.Max = TotalLines lblStatus = "STATUS: Comparing all Do-Not-Call Numbers....Please wait...." DeleteDoNotCall.Refresh TotalLines = 0 TotalDeletes = 0 Open InFile1 For Input As #1 Open OutFile For Output As #3 Do While Not EOF(1) Line Input #1, InLine InLine = Trim(InLine) Phone1 = Right(InLine, 13) Rem * Remove the ) and - of phone number Rem * CASE: (xxx)_xxx-xxxx If (Mid(Phone1, 5, 1)) = " " Then Area1 = Left(Phone1, 3) Phone1 = Area1 & Mid(Phone1, 6, 3) & Right(Phone1, 4) Rem * CASE: xxx/xxxxxxx OR xxxxxxxxxx ElseIf (Mid(Phone1, 9, 1)) <> "-" Then Area1 = Mid(Phone1, 3, 3) If (Mid(Phone1, 6, 1)) <> "/" Then Area1 = Mid(Phone1, 4, 3) Phone1 = Area1 & Right(Phone1, 7) Rem * CASE: (xxx)xxxx-xxxx OR _xxx-xxx-xxxx Else Area1 = Mid(Phone1, 2, 3) Phone1 = Area1 & Mid(Phone1, 6, 3) & Right(Phone1, 4) End If Rem * Push progress bar along TotalLines = TotalLines + 1 ProgressBar1.Value = TotalLines If (Area1 <> "727" And Area1 <> "813" And Area1 <> "352" And Area1 <> "863" And Area1 <> "941" And TotalLines > 1) Then OkayToCall = False TotalDeletes = TotalDeletes + 1 Else Rem * Set flag to true initially OkayToCall = True Rem * Loop to check all Do-Not-Call numbers Open InFile2 For Input As #2 Do While ((Not EOF(2)) And OkayToCall) Line Input #2, Phone2 Phone2 = Trim(Phone2) Rem * compare the two numbers If (Phone1 = Phone2 And TotalLines > 1) Then OkayToCall = False TotalDeletes = TotalDeletes + 1 End If Loop Close #2 End If Rem * if not on Do-Not-Call List, write the input line If OkayToCall Then Print #3, InLine Loop Close #3 Close #1 ProgressBar1.Value = ProgressBar1.Max lblStatus = "STATUS: Done." DeleteDoNotCall.Refresh MsgBox ("DONE! There were " & TotalDeletes & " Do-Not-Call or invalid numbers deleted.") lblInputFile1 = "" lblInputFile2 = "" lblOutputFile1 = "" lblStatus = "STATUS:" ProgressBar1.Value = 0 End If End Sub Rem *********************************************** Rem * Exit DeleteDoNotCall program Rem *********************************************** Private Sub cmdExit_Click() Unload Me End Sub Rem ********************************************** Rem * Get input file name MAIN Rem ********************************************** Private Sub cmdInputFile1_Click() Rem * Select Input File 1 CommonDialog1.Filter = "Text Files (*.*)" CommonDialog1.FilterIndex = 1 CommonDialog1.ShowOpen InputFile1 = CommonDialog1.FileName lblInputFile1 = InputFile1 End Sub Rem ********************************************** Rem * Get input file name Do-Not-Call Rem ********************************************** Private Sub cmdInputFile2_Click() Rem * Select Input File 2 CommonDialog2.Filter = "Text Files (*.*)" CommonDialog2.FilterIndex = 1 CommonDialog2.ShowOpen InputFile2 = CommonDialog2.FileName lblInputFile2 = InputFile2 End Sub Rem ********************************************** Rem * Get output file name MAIN Rem ********************************************** Private Sub cmdOutputFile1_Click() Rem * Select Output File 1 CommonDialog3.Filter = "Text Files (*.*)" CommonDialog3.FilterIndex = 1 CommonDialog3.ShowOpen OutputFile1 = CommonDialog3.FileName lblOutputFile1 = OutputFile1 End Sub