7 Replies - 314 Views - Last Post: 14 October 2019 - 09:25 AM Rate Topic: -----

#1 JonasK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 10

How to create a file name from textbox

Posted 11 October 2019 - 02:00 AM

I'm a newbie .How to create a .txt file name from textbox? Here is my code :
  ...
 filename = TextBox1.Text
 Dim objWriter As New System.IO.StreamWriter("My.Resources.filename.txt", True)
 ...
objWriter.Close()


thank you.
Is This A Good Question/Topic? 0
  • +

Replies To: How to create a file name from textbox

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: How to create a file name from textbox

Posted 11 October 2019 - 07:14 AM

2 filename = TextBox1.Text

Start with that line.
Check if it has a '.txt'.. If not add one.

Then use it here. You know.. where the string for a file name already is.
3 Dim objWriter As New System.IO.StreamWriter("My.Resources.filename.txt", True)

Was This Post Helpful? 0
  • +
  • -

#3 JonasK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 10

Re: How to create a file name from textbox

Posted 14 October 2019 - 04:47 AM

Or so :
.... 
filename = TextBox1.Text & ".txt"
        Dim objWriter As New System.IO.StreamWriter("My.Resources.filename", True)
....       
 objWriter.Close()



Not working.Record file with the same name: filename. And with StreamWriter is it possible at all?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: How to create a file name from textbox

Posted 14 October 2019 - 07:15 AM

Once again you are using a literal string instead of something from a textbox or from the actual resource.

This is a literal string: "My.Resources.filename"
This is a string variable: My.Resources.filename
Was This Post Helpful? 0
  • +
  • -

#5 JonasK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 10

Re: How to create a file name from textbox

Posted 14 October 2019 - 07:37 AM

Can you show me what the code should be? I understand that 'My.Resources' is the file path.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: How to create a file name from textbox

Posted 14 October 2019 - 07:43 AM

How about you try again.

Again - things between the quotes "" is a literal string and treated as such. Something like textbox.text is a string variable.
Was This Post Helpful? 0
  • +
  • -

#7 JonasK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 10

Re: How to create a file name from textbox

Posted 14 October 2019 - 09:24 AM

I was thinking and it works :)/>/>
Dim objWriter As New System.IO.StreamWriter((fileName), True)


thank you, modi123_1!
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: How to create a file name from textbox

Posted 14 October 2019 - 09:25 AM

No problem. The whole 'literal string vs variable' trips folk up now and then.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1