|
-
Nov 25th, 2005, 06:42 AM
#1
Thread Starter
Addicted Member
[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
While I don't agree with what you say, I'll defend to the death your right to say it.
-
Nov 25th, 2005, 06:56 AM
#2
Fanatic Member
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
r0ach™
Don't forget to rate the post
-
Nov 25th, 2005, 07:07 AM
#3
Thread Starter
Addicted Member
Re: Choose Save Destination?
Thanks Roach. Just one last thing how do i select the file type, ie .txt
While I don't agree with what you say, I'll defend to the death your right to say it.
-
Nov 25th, 2005, 07:25 AM
#4
Fanatic Member
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
r0ach™
Don't forget to rate the post
-
Nov 25th, 2005, 07:27 AM
#5
Thread Starter
Addicted Member
Re: Choose Save Destination?
While I don't agree with what you say, I'll defend to the death your right to say it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|