|
-
Apr 8th, 2001, 07:02 PM
#1
Thread Starter
Hyperactive Member
I have a text box and a command button.
How can I have it so that, when the command button is pressed,
what ever is typed in the text box will be saved to the top line of
a file "C:\windows\desktop\orders.txt"?
I don't want to erase what has already been in the text file, just
to add the new information to it.
Thanks for any help!
I.
-
Apr 8th, 2001, 07:06 PM
#2
PowerPoster
Try this:
Code:
' Append to file
Dim FileNumber
FileNumber = FreeFile
Open "C:\Windows\desktop\orders.txt" For Append As FileNumber
Print #FileNumber, Text1.Text
Close FileNumber
-
Apr 8th, 2001, 07:09 PM
#3
PowerPoster
Oh sorry, I just re-read you wanted it at the top of the file...hmmm...you'll have to read in the existing file contents, append Text1.Text to the beginning then output the result, overwriting what is already there.
-
Apr 8th, 2001, 07:09 PM
#4
Frenzied Member
Use For Append:
Code:
Open "C:\windows\desktop\orders.txt" For Append As #1
Put #1, , "String"
...
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Apr 8th, 2001, 07:27 PM
#5
Frenzied Member
Originally posted by chrisjk
Oh sorry, I just re-read you wanted it at the top of the file...hmmm...you'll have to read in the existing file contents, append Text1.Text to the beginning then output the result, overwriting what is already there.
Er...No. The For Can take:
- Append
- Binary
- Input
- Output
- Rendom
So append is very easy.
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Apr 8th, 2001, 07:29 PM
#6
PowerPoster
He wants to append to the beginning. Append only adds to the end of the file
-
Apr 8th, 2001, 07:37 PM
#7
-
Apr 8th, 2001, 07:44 PM
#8
PowerPoster
I know
-
Apr 10th, 2001, 05:41 AM
#9
Thread Starter
Hyperactive Member
Thanks for your help - it did pretty much what I wanted.
But one important development is necessary. How can I program it so that, whatever text is selected in the text box (as opposed to all the text in the box) is added to the text file?
Actually, I think I have it....sorry about that. It's Text1.Seltext, me thinks.
E.g:
' Append to file
Dim FileNumber
FileNumber = FreeFile
Open "C:\Windows\desktop\orders.txt" For Append As FileNumber
Print #FileNumber, Text1.Seltext
Close FileNumber
But how can I save it to the top of the file?
Thanks!
-
Apr 13th, 2001, 06:26 AM
#10
Use
Seek #1,x
to append at the top (x=1)
or
where ever you wish (x=whatever)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|