473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Saving Text Box to File

30
Hi Guys,

I'm new to programming and i am starting a basic project, so far i have done well researching various bits on the net but have come across a problem and wondered if any one would help?

All i am trying to do is:

click a button called save and the info from txtbox_txt.text to go to a .txt file on c:\ drive but i want it to name the file as the date and time the file is created.

any ideas?

p.s i am using visual studio express 2005

Jay!
Oct 13 '07 #1
2 1623
Ali Rizwan
925 512MB
Hi Guys,

I'm new to programming and i am starting a basic project, so far i have done well researching various bits on the net but have come across a problem and wondered if any one would help?

All i am trying to do is:

click a button called save and the info from txtbox_txt.text to go to a .txt file on c:\ drive but i want it to name the file as the date and time the file is created.

any ideas?

p.s i am using visual studio express 2005

Jay!
Hello,
I don't know a lot of VB 2005 but the code i m providing will help you in VB 2005 to save a textbox to a file.

First add a refrence Microsoft Scripting Runtime

Declarations

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim f As File
  3. Dim s As TextStream
  4.  
Now add this code to Save button on Click Event

Expand|Select|Wrap|Line Numbers
  1.  
  2. fso.CreateTextFile(txtpath.text,true)
  3. Set f = fso.GetFile(txtPath.text)
  4. Set s = f.OpenAsTextStream(ForReading)
  5. s.writeline(txtbox_txt.text)
  6.  

Add another textbox named txtpath where you will enter the path and file name

GOODLUCK
ALI
Oct 14 '07 #2
Asprisa
30
Hi There,

Thanks for the reply! I managed to do it a slightly diffrent way in the end, but you set me on the right path, here is what i did!

SaveFileDialog1.FileName = Name + ".txt"
SaveFileDialog1.InitialDirectory = "z:\public_html\handovernotes\"
SaveFileDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"

If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

My.Computer.FileSystem.WriteAllText(SaveFileDialog 1.FileName, RichTextBox1.Text, False)

End If


Thanks for your help!!

Jay
Oct 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
1
by: terrorix | last post by:
I want to save uploaded file to disk. I have this construction: HttpPostedFile myFile = ((HttpRequest)Request).Files; if (myFile != null) { string fn =...
0
by: Karen Grube | last post by:
Hi! I hate to bother you all with this, but I don't know how best to approach a particular task. Here's the deal: Once a month I personally (that is, in my own personal inbox on my...
5
by: Steve Marshall | last post by:
Hi all, I am converting an app which used a picturebox to draw graphs etc onto, then saved them to a file. I can certainly draw things onto a picturbox in VB.NET, but how do I save them to a...
4
by: Dixie | last post by:
I have a spreadsheet that uses VBA code in Access to save itself as a text file. The line is as follows. xl.ActiveSheet.SaveAs CurrentProject.Path & "\Reports\" & DLookup("", "tblButtons",...
5
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to write up a simple image stamper application that stamps the Exif date information from the jpegs that I've taken from my digital camera and saves the new file with the...
8
by: Yu SONG | last post by:
Hi all, What would be the most efficient way to save an array of floats to a file (in text format)? At the moment, my code looks like: /* * Saving an array of floats to a file
0
Ajm113
by: Ajm113 | last post by:
Contributing To: Saving RichTextBox from Tab Control Ok, I have a question what would I use if I wanted to do something like a paste function in a Rich Text Box using the code on that thread?...
3
by: pozze | last post by:
Hi, I've just made the change from ASP to .net. I have a file (code below) that saves a user submitted file to a MS SQL 2005 database. It collects the file name, file size, file type, and lastly...
9
by: Yamasassy | last post by:
HI im having problems to saving to a .txt file, i need to be able to store a number of employees to this file (and beable to open and these files to load in to text boxes)and retrieve then for later...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.