Private Sub cmdSave_Click()
Dim fs As New FileSystemObject
Dim ts As TextStream
Dim blankFolder As Boolean
Dim stFolder As String
Dim SSNum As String
Dim txtObject As Control
Dim bState As Boolean
'Consintrate strings
SSNum = txtSSNum1.Text & "-" & txtSSNum2.Text & "-" & txtSSNum3.Text
stFolder = "C:\My Documents\" & SSNum
'***********************************************
'Check to see if file name was entered
'***********************************************
If txtYourName.Text = "" Then MsgBox "You forgot the Name"
txtYourName.SetFocus
If txtYourName.Text = "" Then Exit Sub
'************************************************
'Check to see if folder ID was entered
'************************************************
If Len(SSNum) <= 10 Then _
MsgBox "You forgot your Social Security Number"
txtSSNum1.SetFocus
If Len(SSNum) <= 10 Then Exit Sub
'************************************************
'Check to see if folder exist
'************************************************
blankFolder = fs.FolderExists(stFolder)
If blankFolder = True Then MsgBox "Folder Exist"
If blankFolder = True Then txtYourName.SetFocus
If blankFolder = True Then Exit Sub
'************************************************
'Check That all txtBox's are filled in
'************************************************
bState = True
For Each txtObject In Me.Controls
If TypeOf txtObject Is TextBox Then
If txtObject.Text = "" Then bState = False
txtObject.SetFocus
Else
End If
Next
If bState = False Then MsgBox "You forgot to fill in an answer"
If bState = False Then Exit Sub
'************************************************
' Make the folder and name it
'************************************************
MkDir ("c:/My Documents/" & SSNum)
MsgBox "Created the folder" & SSNum
'************************************************
' Create the file name and put something in it
'************************************************
Set ts = fs.CreateTextFile("C:/My Documents/" & SSNum & "/" & txtYourName.Text & ".txt")
MsgBox "Created the file " & txtYourName.Text
'************************************************
' Write to file 22 responces
' Write the texBoxes to File
'************************************************
For Each txtObject In Me.Controls
If TypeOf txtObject Is TextBox Then
ts.WriteLine (txtObject.Text)
End If
'************************************************
' THE FIRST THREE BUTTON OPT.
'************************************************
' optInPerson ; optOverThePhone ; optJobShow
'************************************************
'How do you "If" three to see which one is set?
'
'
'************************************************
' THE FIRST TWO BUTTON OPT/
'************************************************
' optAdYes ; optAdNo
'************************************************
If optAdYes.Value = True Then
ts.WriteLine "True"
Else
ts.WriteLine"False"
End If
'************************************************
' THE SECOUND TWO BUTTON OPT.
'************************************************
' optBenefitsYes ; optBenefitsNo
'************************************************
If optBenefitsYes.Value = True Then
ts.WriteLine "True"
Else
ts.WriteLine"False"
End If
'************************************************
' THE SECOUND THREE BUTTON OPT.
'************************************************
'How do you "If" three to see which one is set?
'
'
'************************************************
' Tell you wrote to the file
'************************************************
MsgBox "Wrote to file " & txtYourName.Text
ts.Close
End Sub
'---------------------------------------------------------------------------------------------
Private Sub cmdOpen_Click()
Dim fs As New FileSystemObject
Dim ts As TextStream
Dim blankFolder As Boolean
Dim blankFile As Boolean
Dim SSNum As String
Dim txtObject As Control
Dim stFolder As String
Dim StFile As String
'**************************************************
' Consentrate strings
'**************************************************
SSNum = txtSSNum1.Text & "-" & txtSSNum2.Text & "-" & txtSSNum3.Text
stFolder = "c:\My Documents\" & SSNum
StFile = stFolder & "\" & txtYourName.Text & ".txt"
'*************************************************
'Check to see if file name was entered
'*************************************************
If txtYourName.Text = "" Then MsgBox "You forgot the Name"
txtYourName.SetFocus
If txtYourName.Text = "" Then Exit Sub
'*************************************************
'Check to see if folder ID was entered
'*************************************************
If Len(SSNum) <= 10 Then MsgBox "You forgot your Social Security Number"
txtSSNum1.SetFocus
If Len(SSNum) <= 10 Then Exit Sub
'*************************************************
'Check to see if Folder Exist
'*************************************************
blankFolder = fs.FolderExists(stFolder)
If blankFolder = False Then MsgBox "Folder does not Exist"
'Clear the txtBoxes
If blankFolder = False Then txtYourName.Text = ""
If blankFolder = False Then txtSSNum1.Text = ""
If blankFolder = False Then txtSSNum2.Text = ""
If blankFolder = False Then txtSSNum3.Text = ""
'Reset focus
If blankFolder = False Then txtYourName.SetFocus
'Exit the Sub
If blankFolder = False Then Exit Sub
'*************************************************
'Check to see if File Exist
'*************************************************
blankFile = fs.FileExists(StFile)
If blankFile = False Then MsgBox "File does not Exist"
'Clear the txtBoxes
If blankFile = False Then txtYourName.Text = ""
If blankFile = False Then txtSSNum1.Text = ""
If blankFile = False Then txtSSNum2.Text = ""
If blankFile = False Then txtSSNum3.Text = ""
'Reset focus
If blankFile = False Then txtYourName.SetFocus
'Exit the Sub
If blankFile = False Then Exit Sub
'***************************************************
'Open the file and get the contents
'***************************************************
Set ts = fs.OpenTextFile("C:\My Documents\" & SSNum & "\" & txtYourName.Text & ".Txt")
For Each txtObject In Me.Controls
If TypeOf txtObject Is TextBox Then
ts.ReadLine (txtObject.Text)
End If
Next
'*************************************************
' NOW TO GET OPT RESPONCES
*************************************************
' THE FIRST THREE BUTTON OPT.
'************************************************
' optInPerson ; optOverThePhone ; optJobShow
'************************************************
'How do you "If" three to see which one is set?
'
'
'************************************************
' THE FIRST TWO BUTTON OPT/
'************************************************
' optAdYes ; optAdNo
'************************************************
'
'
'
'************************************************
' THE SECOUND TWO BUTTON OPT.
'************************************************
' optBenefitsYes ; optBenefitsNo
'************************************************
'
'
'
'************************************************
' THE SECOUND THREE BUTTON OPT.
'************************************************
'How do you "If" three to see which one is set?
'
'
'************************************************
' Let them know you opened the file
'************************************************
MsgBox " Opened file " & txtYourName.Text
ts.Close
End Sub