Hey. I have a problem. I am entering data into various textboxes and writing it to a file. I then reading that data in a MSFlexGrid table. I have no problem with that. The only problem is that when the application is closed, the current state of the table is not saved. How can I do that ?
Here's my code, all under the AddDelivery button:
Private Sub cmdAddDelivery_ Click()
Open App.Path & "\deliveries.tx t" For Append As #11
Write #11, txtPName.Text, txtPAddress1.Te xt & ", " & txtPAddress2.Te xt & ", " & cboPTown.Text, cboPPrefix.Text & " " & txtPTelephone.T ext & ", " & cboPMPrefix.Tex t & " " & txtPMobile.Text , txtDName.Text, txtDAddress1.Te xt & ", " & txtDAddress2.Te xt & ", " & cboDTown.Text, cboDPrefix.Text & " " & txtDTelephone.T ext & ", " & cboDMPrefix.Tex t & " " & txtDMobile.Text , txtWeightOfPack age.Text, txtDeliveryPric e.Text, txtPickupDate.T ext, txtDeliveryDate .Text
MsgBox "New Delivery has been Added !", vbInformation, "Success!!! "
txtPName.Text = ""
txtPAddress1.Te xt = ""
txtPAddress2.Te xt = ""
cboPTown.Text = ""
cboPPrefix.Text = "021"
txtPTelephone.T ext = ""
cboPMPrefix.Tex t = "085"
txtPMobile.Text = ""
txtDName.Text = ""
txtDAddress1.Te xt = ""
txtDAddress2.Te xt = ""
cboDTown.Text = ""
cboDPrefix.Text = "021"
txtDTelephone.T ext = ""
cboDMPrefix.Tex t = "085"
txtDMobile.Text = ""
txtWeightOfPack age.Text = ""
txtDeliveryPric e.Text = ""
txtPickupDate.T ext = ""
txtDeliveryDate .Text = ""
txtPName.SetFoc us
Close #11
Open App.Path & "\deliveries.tx t" For Input As #12
Dim oldRow As Long
Dim lngRow As Long
Dim lngCol As Long
Dim strID As String
Dim strPickupName As String
Dim strPickupAdd As String
Dim strPickupTel As String
Dim strDelName As String
Dim strDelAdd As String
Dim strDelTel As String
Dim strWoP As String
Dim strDelPrice As String
Dim strPriority As String
Dim strPickupDate As String
Dim strDelDate As String
Dim counter As Integer
counter = 1
Do Until EOF(12)
Input #12, strPickupName, strPickupAdd, strPickupTel, strDelName, strDelAdd, strDelTel, strWoP, strDelPrice, strPickupDate, strDelDate
MSFlexGrid1.Tex tMatrix(counter , 0) = ""
MSFlexGrid1.Tex tMatrix(counter , 1) = strPickupName
MSFlexGrid1.Tex tMatrix(counter , 2) = strPickupAdd
MSFlexGrid1.Tex tMatrix(counter , 3) = strPickupTel
MSFlexGrid1.Tex tMatrix(counter , 4) = strDelName
MSFlexGrid1.Tex tMatrix(counter , 5) = strDelAdd
MSFlexGrid1.Tex tMatrix(counter , 6) = strDelTel
MSFlexGrid1.Tex tMatrix(counter , 7) = strWoP
MSFlexGrid1.Tex tMatrix(counter , 8) = strDelPrice
MSFlexGrid1.Tex tMatrix(counter , 9) = strPickupDate
MSFlexGrid1.Tex tMatrix(counter , 10) = strDelDate
counter = counter + 1
Loop
MSFlexGrid1.Row s = MSFlexGrid1.Row s + 1
For lngRow = MSFlexGrid1.Row s - 2 To MSFlexGrid1.Row Step -1
For lngCol = 0 To MSFlexGrid1.Col s - 1
MSFlexGrid1.Tex tMatrix(lngRow + 1, lngCol) = MSFlexGrid1.Tex tMatrix(lngRow, lngCol)
If lngRow = MSFlexGrid1.Row Then
MSFlexGrid1.Tex tMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next
Close #12
End Sub
thanks
Here's my code, all under the AddDelivery button:
Private Sub cmdAddDelivery_ Click()
Open App.Path & "\deliveries.tx t" For Append As #11
Write #11, txtPName.Text, txtPAddress1.Te xt & ", " & txtPAddress2.Te xt & ", " & cboPTown.Text, cboPPrefix.Text & " " & txtPTelephone.T ext & ", " & cboPMPrefix.Tex t & " " & txtPMobile.Text , txtDName.Text, txtDAddress1.Te xt & ", " & txtDAddress2.Te xt & ", " & cboDTown.Text, cboDPrefix.Text & " " & txtDTelephone.T ext & ", " & cboDMPrefix.Tex t & " " & txtDMobile.Text , txtWeightOfPack age.Text, txtDeliveryPric e.Text, txtPickupDate.T ext, txtDeliveryDate .Text
MsgBox "New Delivery has been Added !", vbInformation, "Success!!! "
txtPName.Text = ""
txtPAddress1.Te xt = ""
txtPAddress2.Te xt = ""
cboPTown.Text = ""
cboPPrefix.Text = "021"
txtPTelephone.T ext = ""
cboPMPrefix.Tex t = "085"
txtPMobile.Text = ""
txtDName.Text = ""
txtDAddress1.Te xt = ""
txtDAddress2.Te xt = ""
cboDTown.Text = ""
cboDPrefix.Text = "021"
txtDTelephone.T ext = ""
cboDMPrefix.Tex t = "085"
txtDMobile.Text = ""
txtWeightOfPack age.Text = ""
txtDeliveryPric e.Text = ""
txtPickupDate.T ext = ""
txtDeliveryDate .Text = ""
txtPName.SetFoc us
Close #11
Open App.Path & "\deliveries.tx t" For Input As #12
Dim oldRow As Long
Dim lngRow As Long
Dim lngCol As Long
Dim strID As String
Dim strPickupName As String
Dim strPickupAdd As String
Dim strPickupTel As String
Dim strDelName As String
Dim strDelAdd As String
Dim strDelTel As String
Dim strWoP As String
Dim strDelPrice As String
Dim strPriority As String
Dim strPickupDate As String
Dim strDelDate As String
Dim counter As Integer
counter = 1
Do Until EOF(12)
Input #12, strPickupName, strPickupAdd, strPickupTel, strDelName, strDelAdd, strDelTel, strWoP, strDelPrice, strPickupDate, strDelDate
MSFlexGrid1.Tex tMatrix(counter , 0) = ""
MSFlexGrid1.Tex tMatrix(counter , 1) = strPickupName
MSFlexGrid1.Tex tMatrix(counter , 2) = strPickupAdd
MSFlexGrid1.Tex tMatrix(counter , 3) = strPickupTel
MSFlexGrid1.Tex tMatrix(counter , 4) = strDelName
MSFlexGrid1.Tex tMatrix(counter , 5) = strDelAdd
MSFlexGrid1.Tex tMatrix(counter , 6) = strDelTel
MSFlexGrid1.Tex tMatrix(counter , 7) = strWoP
MSFlexGrid1.Tex tMatrix(counter , 8) = strDelPrice
MSFlexGrid1.Tex tMatrix(counter , 9) = strPickupDate
MSFlexGrid1.Tex tMatrix(counter , 10) = strDelDate
counter = counter + 1
Loop
MSFlexGrid1.Row s = MSFlexGrid1.Row s + 1
For lngRow = MSFlexGrid1.Row s - 2 To MSFlexGrid1.Row Step -1
For lngCol = 0 To MSFlexGrid1.Col s - 1
MSFlexGrid1.Tex tMatrix(lngRow + 1, lngCol) = MSFlexGrid1.Tex tMatrix(lngRow, lngCol)
If lngRow = MSFlexGrid1.Row Then
MSFlexGrid1.Tex tMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next
Close #12
End Sub
thanks
Comment