Software Bugs:
1. Control the font format within cells DONE
2. Check user input syntax and characteristics DONE
3. Check if the file exists NOT DONE
4. check if the file is already opened NOT DONE


G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\MainForm.vb 1
1 Option Explicit On
23
Public Class MainForm
45
Private filename As String
6 Private astr As String
7 Private Saveflag As Boolean
8 Private MyWord As Word.Application
9 Private WordDoc As Word.Document
10 Private MyTable As Word.Table
11 Private MyCell As Word.Cell
12 Private MyCols As Word.Columns
13 Private RetSt As String
14 Private i, ro, co, addressflag As Integer
15 Private currdate As Date
16
17
18 Private Sub clearBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearBtn.Click
19
20 frstTxtBox.Text = “”
21 frstTxtBox.BackColor = Color.White
22 midTxtBox.Text = “”
23 midTxtBox.BackColor = Color.White
24 lstTxtBox.Text = “”
25 lstTxtBox.BackColor = Color.White
26 currTxtBox.Text = “”
27 currTxtBox.BackColor = Color.White
28 prevTxtBox.Text = “(Fill in your previous mailing address if you have moved in the last 6 months.) Note: not required by
Equifax and Experian.”
29 prevTxtBox.BackColor = Color.White
30 ssnTxtBox.Text = “333224444 – No Dashes”
31 ssnTxtBox.BackColor = Color.White
32
33 End Sub
34
35 Private Sub exitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitBtn.Click
36 Dispose()
37
38 End Sub
39
40 Private Sub okBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okBtn.Click
41
42 ‘ String Error Check Data
43 ‘============================
44 If strErrorCheck() = 1 Then
45 Exit Sub
46 End If
47
48 If ssnErrorCheck() = 1 Then
49 Exit Sub
50 End If
51
52 Me.WindowState = FormWindowState.Minimized
53 Me.Enabled = False
54 progressFrm.Show()
55
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\MainForm.vb 2
56 If RadioButton1.Checked = True Then
57
58 Call SaveFileName(“doc”, “MS Word Documents”) ‘ Call Save File Dialog to save the output results
59
60 MyWord = CreateObject(“Word.Application”)
61 WordDoc = MyWord.Documents.Add
62
63 MyWord.Visible = True
64
65 Call AddressChange(1)
66 MyWord.Selection.InsertBreak()
67 Call AddressChange(2)
68 MyWord.Selection.InsertBreak()
69 Call AddressChange(3)
70
71 ‘=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
72
73 ‘finaly save the file. If the document exists then will be overwriten
74 WordDoc.SaveAs(filename)
75
76 WordDoc.Application.Quit()
77
78 WordDoc = Nothing
79 MyWord = Nothing
80
81 progressFrm.Button1.Text = “Process is Done”
82
83 ElseIf RadioButton2.Checked = True Then
84
85 Call SaveFileName(“txt”, “Text Documents”) ‘ Call Save File Dialog to save the output results
86
87 End If
88
89 End Sub
90
91 ‘ Save Dailog Method
92 ‘=======================
93 #Region “Save Dailog Method”
94 Private Sub SaveFileName(ByVal str1 As String, ByVal str2 As String)
95
96 On Error GoTo SaveAsErr
97
98 ‘ display the Save dialog
99 SaveFileDialog.AddExtension = True
100 SaveFileDialog.DefaultExt = str1
101 SaveFileDialog.Filter = str2 + ” (*.” + str1 + “)|*.” + str1
102
103 ‘ Check if yes or Cancel btn is clicked
104 ‘ get the resulting filename
105 If SaveFileDialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
106 filename = “opt-out.” + str1
107 Else
108 filename = SaveFileDialog.FileName
109 End If
110
111 SaveAsErr:
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\MainForm.vb 3
112 Exit Sub
113
114 End Sub
115 #End Region
116
117 ‘ Main Code to Generate the Output Results
118 ‘===============================================
119 #Region “Main Code to Generate the Output Results”
120 Private Sub AddressChange(ByVal flag As Integer)
121
122 Dim RetSt As String
123
124 RetSt = Chr(13)
125
126 MyWord.Selection.Font.Name = “Times New Roman”
127 MyWord.Selection.Font.Size = 12
128 MyWord.Selection.Font.Bold = False
129 MyWord.Selection.Font.Underline = Word.WdUnderline.wdUnderlineNone
130 MyWord.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
131
132 Select Case flag
133 Case 1
134 astr = “Equifax, Inc.” + RetSt + “P.O. Box 740123″ + RetSt + “Atlanta, GA 30374-0123″
135 Case 2
136 astr = “Experian” + RetSt + “Consumer Opt-Out” + RetSt + “701 Experian Parkway” + RetSt + “Allen, TX 75013″
137 Case 3
138 astr = “Trans Union Corporation’s” + RetSt + “Name Removal Option” + RetSt + “P.O. Box 97328″ + RetSt + “Jackson,
MS 39288-7328″
139 End Select
140
141 MyWord.Selection.TypeText(astr)
142
143 For i = 1 To 2
144 MyWord.Selection.TypeText(RetSt)
145 Next i
146
147 astr = frstTxtBox.Text + ” ” + lstTxtBox.Text + RetSt + currTxtBox.Text + RetSt
148 MyWord.Selection.TypeText(astr)
149
150 For i = 1 To 2 : MyWord.Selection.TypeText(RetSt) : Next i
151
152 currdate = Date.Now
153
154 astr = “Date: ” + currdate + RetSt
155 MyWord.Selection.TypeText(astr)
156
157 For i = 1 To 2 : MyWord.Selection.TypeText(RetSt) : Next i
158
159 astr = “To whom it may concern: ” + RetSt
160 MyWord.Selection.TypeText(astr)
161
162 For i = 1 To 2 : MyWord.Selection.TypeText(RetSt) : Next i
163
164 astr = “I request to have my name removed from your marketing lists. Here is the information you have asked me to include
in my request:” + RetSt
165 MyWord.Selection.TypeText(astr)
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\MainForm.vb 4
166
167 For i = 1 To 2 : MyWord.Selection.TypeText(RetSt) : Next i
168
169 MyWord.Selection.Font.Size = 11
170
171
172 ‘ Fill out the table
173 ‘=========================
174
175 ro = 6 ‘Numbers of rows
176 co = 2 ‘Numbers of columns
177 MyTable = MyWord.Selection.Tables.Add(MyWord.Selection.Range, ro, co)
178 MyCols = MyTable.Columns
179 MyCols(1).Width = 250
180 MyCols(2).Width = 250
181
182 ‘ Cell (1, 1)
183 MyCell = MyTable.Cell(1, 1)
184 MyCell.Select()
185 MyCell.Split(2)
186 MyWord.Selection.Font.Bold = True
187 MyWord.Selection.TypeText(“FIRST, MIDDLE & LAST NAME”)
188
189 ‘ Cell (2, 1)
190 MyCell = MyTable.Cell(2, 1)
191 MyCell.Select()
192 MyWord.Selection.Font.Bold = False
193 MyWord.Selection.Font.Italic = True
194 MyWord.Selection.TypeText(“(List all name variations, including Jr., Sr., etc.)”)
195
196 ‘ Cell (1, 2)
197 MyCell = MyTable.Cell(1, 2)
198 MyCell.Select()
199 MyWord.Selection.TypeText(frstTxtBox.Text + ” ” + midTxtBox.Text + ” ” + lstTxtBox.Text)
200
201 ‘————————————————————————————–
202 ‘ Cell (3, 1)
203 MyCell = MyTable.Cell(3, 1)
204 MyCell.Select()
205 MyWord.Selection.Font.Bold = True
206 MyWord.Selection.TypeText(“CURRENT MAILING ADDRESS”)
207
208 ‘ Cell (3, 2)
209 MyCell = MyTable.Cell(3, 2)
210 MyCell.Select()
211 MyWord.Selection.TypeText(currTxtBox.Text)
212
213 ‘—————————————————————————————
214 ‘ Cell (4, 1)
215 MyCell = MyTable.Cell(4, 1)
216 MyCell.Select()
217 MyCell.Split(2)
218 MyWord.Selection.Font.Bold = True
219 MyWord.Selection.TypeText(“PREVIOUS MAILING ADDRESS”)
220
221 ‘ Cell (5, 1)
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\MainForm.vb 5
222 MyCell = MyTable.Cell(5, 1)
223 MyCell.Select()
224 MyWord.Selection.Font.Italic = True
225 MyWord.Selection.Font.Bold = False
226 MyWord.Selection.TypeText(“(Fill in your previous mailing address if you have moved in the last 6 months.)” + RetSt +
“Note: not required by Equifax and Experian.”)
227
228 If flag = 3 Then
229 MyCell = MyTable.Cell(4, 2)
230 MyCell.Select()
231 MyWord.Selection.TypeText(prevTxtBox.Text)
232 Else
233 MyCell = MyTable.Cell(4, 2)
234 MyCell.Select()
235 MyWord.Selection.TypeText(“”)
236 End If
237
238 ‘ Cell (6, 1)
239 MyCell = MyTable.Cell(6, 1)
240 MyCell.Select()
241 MyCell.Split(2)
242 MyWord.Selection.Font.Bold = True
243 MyWord.Selection.TypeText(“SOCIAL SECURITY NUMBER”)
244
245 ‘ Cell (7, 1)
246 MyCell = MyTable.Cell(7, 1)
247 MyCell.Select()
248 MyWord.Selection.Font.Bold = False
249 MyWord.Selection.Font.Italic = True
250 MyWord.Selection.TypeText(“Note: not required by Experian.”)
251
252 If flag = 1 Or flag = 3 Then
253 MyCell = MyTable.Cell(6, 2) : MyCell.Select() : MyWord.Selection.TypeText(ssnTxtBox.Text)
254 Else
255 MyCell = MyTable.Cell(6, 2) : MyCell.Select() : MyWord.Selection.TypeText(“”)
256 End If
257
258 ‘ Cell (8, 1)
259 MyCell = MyTable.Cell(8, 1)
260 MyCell.Select()
261 MyCell.Split(2)
262 MyWord.Selection.Font.Bold = True
263 MyWord.Selection.TypeText(“DATE OF BIRTH”)
264
265 ‘ Cell (9, 1)
266 MyCell = MyTable.Cell(9, 1)
267 MyCell.Select()
268 MyWord.Selection.Font.Bold = False
269 MyWord.Selection.Font.Italic = True
270 MyWord.Selection.TypeText(“Note: not required by Equifax and Experian.”)
271
272 If flag = 3 Then
273 MyCell = MyTable.Cell(8, 2) : MyCell.Select() : MyWord.Selection.TypeText(DateTimePicker.Value.ToShortDateString)
274 Else
275 MyCell = MyTable.Cell(8, 2) : MyCell.Select() : MyWord.Selection.TypeText(“”)
276 End If
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\MainForm.vb 6
277
278 ‘Exit from table
279 MyCell = MyTable.Cell(10, 2) : MyCell.Select()
280 MyCell = Nothing
281 MyWord.Selection.GoToNext(Word.WdGoToItem.wdGoToLine)
282
283 For i = 1 To 3 : MyWord.Selection.TypeText(RetSt) : Next i
284
285 MyWord.Selection.Font.Size = 12
286
287 MyWord.Selection.TypeText(“Thank you for your prompt handling of my request.”)
288
289 For i = 1 To 3 : MyWord.Selection.TypeText(RetSt) : Next i
290
291 MyWord.Selection.TypeText(“_______________________________”)
292 MyWord.Selection.TypeText(RetSt)
293 MyWord.Selection.Font.Bold = True
294 MyWord.Selection.Font.Size = 10
295 MyWord.Selection.TypeText(“SIGNATURE of ” + frstTxtBox.Text + ” ” + lstTxtBox.Text)
296
297
298 End Sub
299 #End Region
300
301 ‘ Mouse Clicked Events
302 ‘=========================
303 #Region “Mouse Clicked Methods”
304 Private Sub frstTxtBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frstTxtBox.
MouseClick
305
306 frstTxtBox.Text = “”
307 frstTxtBox.BackColor = Color.White
308
309 End Sub
310
311 Private Sub midTxtBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles midTxtBox.
MouseClick
312
313 midTxtBox.Text = “”
314 midTxtBox.BackColor = Color.White
315
316 End Sub
317
318 Private Sub lstTxtBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstTxtBox.
MouseClick
319
320 lstTxtBox.Text = “”
321 lstTxtBox.BackColor = Color.White
322
323 End Sub
324
325 Private Sub currTxtBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles currTxtBox.
MouseClick
326
327 currTxtBox.Text = “”
328 currTxtBox.BackColor = Color.White
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\MainForm.vb 7
329
330 End Sub
331
332 Private Sub prevTxtBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles prevTxtBox.
MouseClick
333
334 prevTxtBox.Text = “”
335 prevTxtBox.BackColor = Color.White
336
337 End Sub
338
339 Private Sub ssnTxtBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ssnTxtBox.
MouseClick
340
341 ssnTxtBox.Text = “”
342 ssnTxtBox.BackColor = Color.White
343
344 End Sub
345
346 #End Region
347
348 End Class
349
____________________________________________________________________________________________________
====================================================================================================
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\ErrorCheck.vb 1
1 Module ErrorCheck
23
#Region “String Error Check”
4 Public Function strErrorCheck() As Integer
56
If MainForm.frstTxtBox.Text = “” Then
7 MsgBox(“Please, Enter your First Name”, vbCritical)
8 MainForm.frstTxtBox.BackColor = Color.Yellow
9 strErrorCheck = 1
10 Exit Function
11 End If
12
13 If MainForm.midTxtBox.Text = “” Then
14 MsgBox(“Please, Enter your Middle Name or select the middle Name Text Field and then press the spaceBar”, vbCritical)
15 MainForm.midTxtBox.BackColor = Color.Yellow
16 strErrorCheck = 1
17 Exit Function
18 End If
19
20 If MainForm.lstTxtBox.Text = “” Then
21 MsgBox(“Please, Enter your Last Name”, vbCritical)
22 MainForm.lstTxtBox.BackColor = Color.Yellow
23 strErrorCheck = 1
24 Exit Function
25 End If
26
27 If MainForm.currTxtBox.Text = “” Then
28 MsgBox(“Please, Enter your Current Address”, vbCritical)
29 MainForm.currTxtBox.BackColor = Color.Yellow
30 strErrorCheck = 1
31 Exit Function
32 End If
33
34 If MainForm.prevTxtBox.Text = “” Then
35 MsgBox(“Please, Enter your Previous Address or select Previous Address Text Field and then press the spaceBar”,
vbCritical)
36 MainForm.prevTxtBox.BackColor = Color.Yellow
37 strErrorCheck = 1
38 Exit Function
39 End If
40
41 End Function
42
43 #End Region
44
45 #Region “SSN Error Check”
46 Public Function ssnErrorCheck() As Integer
47
48 Dim iLength As Integer
49 Dim ssnStr As String
50 Dim str As String
51
52
53 iLength = Trim(MainForm.ssnTxtBox.Text).Length()
54
55 If Not IsNumeric(MainForm.ssnTxtBox.Text) Then
G:\Documents and Settings\nemo\My Documents\Visual Studio 2005\Projects\Opt-Out\Opt-Out\ErrorCheck.vb 2
56 MsgBox(“Please, Enter a 9 Digits SSN”, MsgBoxStyle.Critical)
57 MainForm.ssnTxtBox.BackColor = Color.Yellow
58 ssnErrorCheck = 1
59 Exit Function
60 End If
61
62 If Not (iLength = 9) Then
63 MsgBox(“Please, Enter a 9 Digits SSN”, MsgBoxStyle.Critical)
64 MainForm.ssnTxtBox.BackColor = Color.Yellow
65 ssnErrorCheck = 1
66 Exit Function
67 End If
68
69 str = Trim(MainForm.ssnTxtBox.Text)
70 ssnStr = Mid(str, 1, 3) + “-” + Mid(str, 4, 2) + “-” + Mid(str, 6, 4)
71 MainForm.ssnTxtBox.Text = ssnStr
72
73 End Function
74
75 #End Region
76
77 End Module
78