A Little problem with CommonDialog control, please help me.
Hi All:wave:
I have something like this
Code:
Private Sub cmdSave_Click()
Dim strBuffer As String
Dim intDemoFileNbr As Integer
Dim strFileToSave As String
On Error GoTo cmdSave_Click_Exit
With dlgDemo
.CancelError = True
.InitDir = mstrLastDir
.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist
.FileName = ""
.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*"
.ShowSave
strFileToSave = .FileName
End With
On Error GoTo cmdSave_Click_Error
intDemoFileNbr = FreeFile
Open strFileToSave For Binary Access Write As #intDemoFileNbr
strBuffer = txtTestFile.Text
Put #intDemoFileNbr, , strBuffer
Close #intDemoFileNbr
mstrLastDir = Left$(strFileToSave, InStrRev(strFileToSave, "\") - 1)
Exit Sub
cmdSave_Click_Error:
MsgBox "The following error has occurred:" & vbNewLine _
& "Err # " & Err.Number & " - " & Err.Description, _
vbCritical, _
"Save Error"
cmdSave_Click_Exit:
End Sub
Unfortunatelly, now I want to save into txt file my data that are in a 5 textboxes. How I should to do it? How to save and how I should to back read into this 5 textboxes. Someone know?
Thanks in advance:thumb:
Tamgovb
Re: A Little problem with CommonDialog control, please help me.
Try
Code:
Open strFileToSave For Append As #1
Print #1, Text1.Text
Print #1, Text2.Text
Print #1, Text3.Text
Print #1, Text4.Text
Print #1, Text5.Text
Close #1
Re: A Little problem with CommonDialog control, please help me.
Choose the appropriate file mode depending on if you want to add data to an existing file or create a new file to save just that info to. Modes: Output or Append (append will require you to make sure the file doesnt already exist and use Kill to delete it if it does).