Results 1 to 5 of 5

Thread: [RESOLVED] Choose Save Destination?

  1. #1

    Thread Starter
    Addicted Member oldmcgroin's Avatar
    Join Date
    Jul 2005
    Location
    Manchester, UK
    Posts
    182

    Resolved [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:
    1. Private Sub cmdSave_Click()
    2.  
    3. Open "c:\ItemList().txt" For Output As #1
    4. For i = 0 To lstSelected.ListCount - 1
    5. Print #1, lstSelected.List(i)
    6. Print #1, ""
    7. Next
    8. Print #1, "TOTAL PRICE: ", Format(txtPrice.Text, "currency")
    9. Close #1
    10.  
    11. End Sub

    Thanks
    While I don't agree with what you say, I'll defend to the death your right to say it.

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Re: Choose Save Destination?

    Use the Common Dialog Control.
    VB Code:
    1. CommonDialog1.Filename = ""
    2. On Error Resume Next
    3. CommonDialog1.ShowSave
    4. If Err.Number = 0 Then
    5.   Open CommonDialog1.Filename For Output As #1
    6.   For i = 0 To lstSelected.ListCount - 1
    7.     Print #1, lstSelected.List(i)
    8.     Print #1, ""
    9.   Next
    10.   Print #1, "TOTAL PRICE: ", Format(txtPrice.Text, "currency")
    11.   Close #1
    12. End If

    r0ach™
    Don't forget to rate the post

  3. #3

    Thread Starter
    Addicted Member oldmcgroin's Avatar
    Join Date
    Jul 2005
    Location
    Manchester, UK
    Posts
    182

    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.

  4. #4
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Re: Choose Save Destination?

    set the filter property.
    VB Code:
    1. '// the string is text to show|filter|text to show|filter
    2. CommonDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
    3. CommonDialog1.FilterIndex = 1 '// this will put (*.txt) as default

    r0ach™
    Don't forget to rate the post

  5. #5

    Thread Starter
    Addicted Member oldmcgroin's Avatar
    Join Date
    Jul 2005
    Location
    Manchester, UK
    Posts
    182

    Re: Choose Save Destination?

    awesome, thanks roach.
    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
  •  



Click Here to Expand Forum to Full Width