How can i keep my data constant after quitting from program. For example:-
If i have entered Potato in any text box. when quit and reopen the program the word potato remains their.
|
Go4Expert Founder
|
![]() |
| 7Mar2010,18:38 | #2 |
|
Save them to a file and reload the content from file when you run next time.
viv345
like this
|
|
Go4Expert Founder
|
![]() |
| 8Mar2010,10:44 | #4 |
|
I don't think that is a good idea and any application specific data should be stored in registry and not user specific data of what he enters. Just semantics.
viv345
like this
|
|
Contributor
|
|
| 10Mar2010,10:20 | #5 |
|
How? Any example. Please
Thanks |
|
Pro contributor
|
![]() |
| 10Mar2010,12:47 | #6 |
|
first of all name your vb version
for example vb6 , vb2008
viv345
like this
|
|
Contributor
|
|
| 11Mar2010,10:11 | #7 |
|
In VB6
|
|
Pro contributor
|
![]() |
| 12Mar2010,16:24 | #8 |
|
with the file method
================== you need a form with a textbox named text1 Code:
Option Explicit Dim filename As String Dim filepath As String Dim text As String Private Sub Form_Load()'when you load form ,checks if the file exists and reads data and stores to text var. and textbox1 filename = "datastore.txt" filepath = App.Path + "\" + filename Dim f As Integer f = FreeFile If Dir(filepath) = filename Then Open filepath For Input As #f Line Input #f, text Text1.text = text Close #f End If End Sub Private Sub Form_Terminate()'when the form terminates,exits-->save text to file Dim f As Integer f = FreeFile Open filepath For Output As #f Print #f, text Close #f End Sub Private Sub Text1_Change()'when you alter text save it to text variable text = Text1.text End Sub
viv345
like this
|
|
Contributor
|
|
| 13Mar2010,15:04 | #9 |
|
Tried:
Given : filepath = App.Path + "\" + filename as C:\Datastore.text and form 1 with text1.text BUT IT not worked Project attached |
|
Pro contributor
|
![]() |
| 14Mar2010,04:37 | #10 |
|
the program works great when you press X to close your form.
I never told you anything about a command button. If you want to end your program with a command button then before "end" copy paste the form_terminate() code like the code below Code:
Private Sub Command1_Click() Dim f As Integer f = FreeFile Open filepath For Output As #f Print #f, text Close #f End End Sub |



