Visual Basic/VB6


QUESTION: Sir how can i save the data that i enterd to a text box for next time.i want to appear that data when next time i load the form

ANSWER: you can save the data in a text file or an access database.

[an error occurred while processing this directive]---------- FOLLOW-UP ----------

QUESTION: can u show me the codes to how to do that.thnk u for your answer sir

ANSWER: Option Explicit
Dim entry As String
'this puts the text into the textfile
Private Sub Command1_Click()
Open "C:\Rtest1.txt" For Output As #2 ' WRITE TO FILE
' you can change the textfile and path to suit you.
Print #2, Text1

Close #2
End Sub

' this puts the string into the textbox
Private Sub Command2_Click()
Open "C:\Rtest1.txt" For Input As #3 ' Read from FILE
' should be same path and name as in command1 click
Line Input #3, entry
Text1 = entry
Close #3
End Sub

---------- FOLLOW-UP ----------

QUESTION: thank you very much sir i got it.but i run the programme and cmd1 click text in textbox1 correctly save in a text file that given path.if i run programme again text in the txt file is lost and new text in the textbox1 is save in that txt file.all i want to keep that old one and add new text to the same txt file.(i dont want to load text files as your reply in cmd2)

put a text box, 1 list box and 3 command buttons on form.

add code:

Private Sub Command1_Click()
' this is to be done for the first time to open the file and add the 1st record
Open "c:\sample.txt" For Output As #1

Print #1, Text1

Close #1
End Sub

Private Sub Command2_Click()
'this is for adding the next records. if you use the first, it will overwrite the file
Open "c:\sample.txt" For Append As #1

Print #1, Text1

Close #1

End Sub

Private Sub Command3_Click()
Dim variable1 As String
Open "c:\sample.txt" For Input As #1

Do While Not EOF(1)
Input #1, variable1

List1.AddItem variable1

Close #1
End Sub

if you want more features you need to study text files creation or use an access database. cannot be solved by asking questions.

Visual Basic

All Answers

Answers by Expert:

Ask Experts




visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.(VB6) basic questions in vb 2008. Optional: 1)a large number of people want me to do work which takes some time and effort. can do projects in vb 2008. Pl.note that i would like to be paid for such work. 2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 3) if you are pleased with my reply you could consider a good amount. 4) you can visit my website


programming since the past 15 years. have completed a large number of projects in Industrial applications, finance,accounts, correspondence. excel macros etc

engineering, management degrees.

Past/Present Clients
project work for a Norway company,USA company and a Canadian company completed. Freelance Project work and Teaching. helping programmers with their work
teaching vb

©2017 All rights reserved.

[an error occurred while processing this directive]