Results 1 to 17 of 17

Thread: How do I prompt the user where to save thier file? (In this case .txt)

  1. #1

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Question How do I prompt the user where to save thier file? (In this case .txt)

    I wanted to know how my users can write something in a textbox, then allow them to save it as a .txt file.
    Last edited by sn3akyr4bb1t; May 12th, 2009 at 08:33 PM. Reason: edit

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How can I add a "Save" button on my form?

    How far have you got so far?

    Show us your code and we can give you some pointers.

  3. #3

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How can I add a "Save" button on my form?

    I made a form, with just a TextBox. I want my users to type something like "Hello" and be able to save it as a .txt file anywhere on there pc.

  4. #4
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How can I add a "Save" button on my form?

    I mean what have you found out about saving text files so far?

  5. #5

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How can I add a "Save" button on my form?

    I found the "SaveFileDialog" in the ToolBox, but I don't know the codes.

  6. #6
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: How can I add a "Save" button on my form?

    google before you post
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  7. #7

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How can I add a "Save" button on my form?

    Quote Originally Posted by Vectris View Post
    google before you post
    I did, found nothing.

  8. #8
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How can I add a "Save" button on my form?

    Quote Originally Posted by sn3akyr4bb1t View Post
    I found the "SaveFileDialog" in the ToolBox, but I don't know the codes.
    All the SaveFileDialog does is allows the user to browse for the folder and set the filename they want you to use for saving the file.

    You need to write your own code to save the file.

    As Vectris said - try googling "save text file vb.net" and you will find thousands upon thousands of examples of how to do this.

  9. #9
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How can I add a "Save" button on my form?

    Quote Originally Posted by sn3akyr4bb1t View Post
    I did, found nothing.
    I find that amazingly hard to believe. I got over 1.3 million pages returned by my google query.

  10. #10

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How can I add a "Save" button on my form?

    Ok, will did this ever come to your mind that maybe our keywords were different?

  11. #11

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How can I add a "Save" button on my form?

    Quote Originally Posted by keystone_paul View Post
    All the SaveFileDialog does is allows the user to browse for the folder and set the filename they want you to use for saving the file.

    You need to write your own code to save the file.

    As Vectris said - try googling "save text file vb.net" and you will find thousands upon thousands of examples of how to do this.
    I will try again.

  12. #12

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How can I add a "Save" button on my form?

    Guys need to go somewhere, be back in like 1 hour as of this post.

  13. #13
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How can I add a "Save" button on my form?

    Quote Originally Posted by sn3akyr4bb1t View Post
    Ok, will did this ever come to your mind that maybe our keywords were different?
    If you seriously didn't get anything back because our keywords were wildly different perhaps you need to think more deeply about how you phrase your questions.

    For example the title of this topic is "How can I add a 'Save' button on my form?"

    The answer to that is really simple - open your form, click on the button icon on the toolbox and click on the form and draw a button of the required size and set the button's text and name to reflect the fact it is a save button.

    Your actual question is really "how do I write a text file" (and possibly also "how do I prompt the user where to save his file").

    I'm not trying to be sarcastic or unhelpful but you need to be able to understand what the root of your question is or you'll never get anywhere.

  14. #14

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How can I add a "Save" button on my form?

    Quote Originally Posted by keystone_paul View Post
    If you seriously didn't get anything back because our keywords were wildly different perhaps you need to think more deeply about how you phrase your questions.

    For example the title of this topic is "How can I add a 'Save' button on my form?"

    The answer to that is really simple - open your form, click on the button icon on the toolbox and click on the form and draw a button of the required size and set the button's text and name to reflect the fact it is a save button.

    Your actual question is really "how do I write a text file" (and possibly also "how do I prompt the user where to save his file").

    I'm not trying to be sarcastic or unhelpful but you need to be able to understand what the root of your question is or you'll never get anywhere.
    Ok, I will rename my post. (By the way, almost everyone here talks to me either sarcastic or unhelpful)

  15. #15
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: How do I prompt the user where to save thier file? (In this case .txt)

    Quote Originally Posted by sn3akyr4bb1t
    (By the way, almost everyone here talks to me either sarcastic or unhelpful)
    Is it really such a mystery why?

  16. #16

    Thread Starter
    Banned
    Join Date
    Apr 2009
    Posts
    114

    Re: How do I prompt the user where to save thier file? (In this case .txt)

    Quote Originally Posted by ForumAccount View Post
    Is it really such a mystery why?
    What were you thinking before you just made that post? Do you think that what you just said helped me prompt a user where to save their file? Think about it.

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do I prompt the user where to save thier file? (In this case .txt)

    I think ForumAccount's post was supposed to prompt you to think about why apparently everyone responds to your questions with sarcasm. I can tell you that it's because you seem to make very little effort to find information for yourself and even when people do provide instructions you make no effort to follow them. You appear to just want other people to write your code for you. People who have worked hard to learn what they know often enjoy sharing it with others who are also prepared to work hard. They are generally not so keen to share with those who won't make a similar effort for themselves.

    You said in post #5 that you know about the SaveFileDialog. I just went to Google and entered savefiledialog. The very first match was the MSDN documentation for the SaveFileDialog class, which contains this code example:
    vb.net Code:
    1. Private Sub button1_Click(sender As Object, e As System.EventArgs)
    2.     Dim myStream As Stream
    3.     Dim saveFileDialog1 As New SaveFileDialog()
    4.  
    5.     saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
    6.     saveFileDialog1.FilterIndex = 2
    7.     saveFileDialog1.RestoreDirectory = True
    8.  
    9.     If saveFileDialog1.ShowDialog() = DialogResult.OK Then
    10.         myStream = saveFileDialog1.OpenFile()
    11.         If (myStream IsNot Nothing) Then
    12.             ' Code to write the stream goes here.
    13.             myStream.Close()
    14.         End If
    15.     End If
    16. End Sub
    If you didn't find that yourself then you didn't try. If you don't try then very few people here will be keen to help you.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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