![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Apr 2006
Location: orange park Fl
Posts: 53
Rep Power: 3
![]() |
:banana: ok i am making a chore program but uh yah say i have a textbox and i want to be able to save the text in it so it wont change when i turn it off and back on so it will still be in the textbox what do i do?? :banana:
|
|
|
|
|
|
#2 |
|
Expert Programmer
|
You will have to write the text to a file, which is quite easy:
To write: Open "c:\file.txt" For input As #1 print #1, "hello" Close #1 To read: Open "c:\file.txt" For Output As #1 Do While Not EOF(1) Line Input #1, data List1.AddItem data Loop Close #1 that should do it for ya. Just copied it out of an old project of mine. Look up a tutorial on reading and writing to files for a more in depth look. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Apr 2006
Location: orange park Fl
Posts: 53
Rep Power: 3
![]() |
when i use the first code it says bad file mode
|
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
To read, open for input. To write, open for output. He just got'em backward. I'm sure if you even read the code instead of copy 'n paste, you would've seen it.
|
|
|
|
|
|
#5 |
|
Expert Programmer
|
lol, my bad. it was a while back. I did have to edit them a bit. bah. owell, all is good :banana: I thought the read code was right as I pulled it out of a program that I still use. surprisingly, I compiled it with the code as 'input' but never save it so it still read output.
![]() |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Apr 2006
Location: orange park Fl
Posts: 53
Rep Power: 3
![]() |
oh well it still wont put the text from the textbox into the text file
|
|
|
|
|
|
#7 |
|
Expert Programmer
|
did you edit it a bit? you didnt just copy and paste did you. Because list1.additem isnt what you want. I'm looking at it now dude, if you make the small shanges yourself you should get this:
'write
Open "c:\file.txt" For Output As #1
Print #1, "hello2"
Close #1
'read
Open "c:\file.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, Data
Text1.Text = Data
Loop
Close #1That works. |
|
|
|
|
|
#8 |
|
Programmer
Join Date: Apr 2006
Location: orange park Fl
Posts: 53
Rep Power: 3
![]() |
what is the code to hide the program to the taskbar
|
|
|
|
|
|
#9 |
|
Expert Programmer
|
Check your other post, and perhaps PM a mod to delete the other one.(looks like you created it twice)
|
|
|
|
|
|
#10 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|