[RESOLVED] Choose Save Destination?
Hey guys, i have this code that saves a listbox to a text file to c:\ItemList().txt
what i wanted to know was how can the user specify where he/she wants to save this document, ie save destination?
VB Code:
Private Sub cmdSave_Click()
Open "c:\ItemList().txt" For Output As #1
For i = 0 To lstSelected.ListCount - 1
Print #1, lstSelected.List(i)
Print #1, ""
Next
Print #1, "TOTAL PRICE: ", Format(txtPrice.Text, "currency")
Close #1
End Sub
Thanks
Re: Choose Save Destination?
Use the Common Dialog Control.
VB Code:
CommonDialog1.Filename = ""
On Error Resume Next
CommonDialog1.ShowSave
If Err.Number = 0 Then
Open CommonDialog1.Filename For Output As #1
For i = 0 To lstSelected.ListCount - 1
Print #1, lstSelected.List(i)
Print #1, ""
Next
Print #1, "TOTAL PRICE: ", Format(txtPrice.Text, "currency")
Close #1
End If
Re: Choose Save Destination?
Thanks Roach. Just one last thing how do i select the file type, ie .txt
Re: Choose Save Destination?
set the filter property.
VB Code:
'// the string is text to show|filter|text to show|filter
CommonDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
CommonDialog1.FilterIndex = 1 '// this will put (*.txt) as default
Re: Choose Save Destination?