How can you use a variable as a text file name in visual basic?
-
When i press a button in visual basic it creates a variable, i would like to use that variable as the name of a text file, is this possible?
-
Answer:
You can use a string variable to hold the file name . The path and name of the file can be hard coded, assigned from a textbox.text property or can be determind by the use of a dialog box which allows the user to browse to a specific file. dim dlg as new OpenFileDialog dim sPath as string with dlg . filter = "All Files (*.*)|*.*|Text File (*.txt)|*.txt" if .showdialog = cancel then exit sub else sPath = .filename end if
Joe at Yahoo! Answers Visit the source
Other answers
Why can't you just Dim the variable and create the text file on two separate lines of code? You're going to give yourself a monstrous headache if you have to refer to that file by way of regular expressions from that point forward.
Mr. Goldsmith
Related Q & A:
- Can I use a variable to name other variables?Best solution by Stack Overflow
- How can I use a button to retrieve a phone 'number' from contacts?Best solution by Stack Overflow
- How can we use our PC as a voice recorder?Best solution by Yahoo! Answers
- How can I send a file to a friend on Hotmail?Best solution by askdavetaylor.com
- How can i export my contacts to a csv file?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.