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.
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.
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.
Re: How can I add a "Save" button on my form?
I mean what have you found out about saving text files so far?
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.
Re: How can I add a "Save" button on my form?
Re: How can I add a "Save" button on my form?
Quote:
Originally Posted by
Vectris
google before you post
I did, found nothing.
Re: How can I add a "Save" button on my form?
Quote:
Originally Posted by
sn3akyr4bb1t
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.
Re: How can I add a "Save" button on my form?
Quote:
Originally Posted by
sn3akyr4bb1t
I did, found nothing.
I find that amazingly hard to believe. I got over 1.3 million pages returned by my google query.
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?
Re: How can I add a "Save" button on my form?
Quote:
Originally Posted by
keystone_paul
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.
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.
Re: How can I add a "Save" button on my form?
Quote:
Originally Posted by
sn3akyr4bb1t
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.
Re: How can I add a "Save" button on my form?
Quote:
Originally Posted by
keystone_paul
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)
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?
Re: How do I prompt the user where to save thier file? (In this case .txt)
Quote:
Originally Posted by
ForumAccount
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.
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:
Private Sub button1_Click(sender As Object, e As System.EventArgs)
Dim myStream As Stream
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = saveFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
' Code to write the stream goes here.
myStream.Close()
End If
End If
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.