How can i create a textfile that include the data of two
textboxes on my form and save it on a disk?
Printable View
How can i create a textfile that include the data of two
textboxes on my form and save it on a disk?
You can use some thing like this:
mytxtfile = App.Path & "\txtfile.txt"
Open mytxtfile For Output As #1 ' Open file for input.
txttosave = text1.Text
Write #1, txttosave
Close #1
,,,,,,,,,,,,,,,,,,
Try and work arround
Regards
The old way to do this would be to use File I/O or Input/Output, but the way that Microsoft would like you to do it now is to use File System Objects.
First, you need to add a referrence to the Microsoft Scripting Runtime component. Having done that, declare the following variable:
Then the function that you use to write to the text file will beCode:Dim FSys As New FileSystemObject
Hope that helps :-) Run a search on File System Objects and you should get more help if you need it.Code:Dim OutStream as Textstream
Set OutStream = FSys.CreateTextfile("C:\windows\mytext.txt")
Outstream.Write(Text1.text & Text2.text)
'and to finish off, save system resources by clearing
'OutStream - not necessary, but a good habit...
Set OutStream = Nothing
how can i set data of textbox 1 in line 1
and data of textbox to line 2 of an created txtfile?
To put data from one textbot into a txtfile is easy
but how can i put data into 2 seperatet lines from 2 seperatet text boxes?????????
Code:Dim OutStream as Textstream
Set OutStream = FSys.CreateTextfile("C:\windows\mytext.txt")
Outstream.Write(Text1.text & vbCrLf & Text2.text)
'and to finish off, save system resources by clearing
'OutStream - not necessary, but a good habit...
Set OutStream = Nothing
Nope...it doesnt work!
any else ideas?
its very important!!!