Private Sub cmdDelete_Click()
strName = ""
strCompany = ""
strMobile = ""
strHome = ""
strAddress = ""
strEmail = ""
Dim strWName() As String
Dim strWHome() As String
Dim strWMobile() As String
Dim strWCompany() As String
Dim strWEmail() As String
Dim strWAddress() As String
Dim intCount As Integer
Dim strNCheck As String
strNCheck = cboTitle.Text
' If all the data is in correct format, then writes to the file
Dim intFile As Integer
Dim intArray As Integer
intFile = FreeFile
Dim strPath As String
strPath = App.Path & "\Books1.appt"
' Opens the original file and inputs all the data same as lblDayNum_Click(Index As Integer) except all data _
is inputted
Open strPath For Input Lock Write As #intFile
Do While Not EOF(intFile)
Input #intFile, strName, strHome, strMobile, strCompany, strEmail, strAddress
If strName <> strNCheck Then
MsgBox strName
intArray = intArray + 1
If intArray = 1 Then
ReDim strWName(1) As String
ReDim strWHome(1) As String
ReDim intWMobile(1) As String
ReDim intWCompany(1) As String
ReDim intWEmail(1) As String
ReDim intWAddress(1) As String
Else
ReDim strWName(intArray) As String
ReDim strWHome(intArray) As String
ReDim intWMobile(intArray) As String
ReDim intWCompany(intArray) As String
ReDim intWEmail(intArray) As String
ReDim intWAddress(intArray) As String
End If
strWName(intArray) = strName
strWHome(intArray) = strHome
intWMobile(intArray) = strMobile
intWCompany(intArray) = strCompany
intWEmail(intArray) = strEmail
intWAddress(intArray) = strAddress
End If
Loop
Close #intFile
intFile = FreeFile
' Opens a temporary file
Open "temps.appt" For Output As #intFile
For intCount = 1 To intArray
If strName = strNCheck Then
Write #intFile, strName, strHome, strMobile, strCompany, strEmail, strAddress
End If
Next intCount
' Deletes the original file and renames the temporary file as the original file
Kill strPath
On Error Resume Next
Kill "Books1.appt"
Close #intFile
Name "temps.appt" As "Books1.appt"
cboTitle.Text = ""
txtMobile.Text = ""
txtHome.Text = ""
txtEmail.Text = ""
txtAddress.Text = ""
txtCompany.Text = ""
End Sub