Hey All,
I need to know the basic code on how to write to a text file using a textbox, and then retrieve it back when i do a search from a texbox.
Any help would be great
Thanks Jason
Printable View
Hey All,
I need to know the basic code on how to write to a text file using a textbox, and then retrieve it back when i do a search from a texbox.
Any help would be great
Thanks Jason
To write to the file:
VB Code:
Open "C:\test.txt" For Output As #1 Print #1, "Say something here" Close #1
I don't remember the code for retrieving from the text file, as I haven't found much use for it ever since I found the RichTextBox.SaveFile and RichTextBox.LoadFile functions.
My advice would be to use the rich text box instead, it's much easier.
Thanks hothead.
On your advise what would be the code to write/read to this richtextbox.
example for writing
======================
Open "C:\test.tft" For Output As #1
Print #1, "Say something here"
Close #1
=======================
How would you read ??
Thanks
You could do something like:
Dim strYourText As String
Open "C:\detlog.txt" For Input As #1
Do Until EOF(1) = True
Input #1, strYourText
Text1.Text = Text1.Text & strYourText
Loop
All depends on how you want to read it.
The syntax to write to a file using a rich text box is different from that of a regular text box. It would be something like this:
VB Code:
RichTextBox1.SaveFile App.Path & "\Test.txt", RTF_TEXT
And here's how to read from the file:
VB Code:
RichTextBox1.LoadFile App.Path & "\Test.txt", RTF_TEXT