Connecting Tech Pros Worldwide Forums | Help | Site Map

How to save text data in my programme

Newbie
 
Join Date: Apr 2007
Location: I live in Sri Lanka.
Posts: 21
#1: Apr 10 '07
hi,
is any one can help me? i have create a form and it have 3 text boxes..and i want to type some data in that text boxes and when i click save button i want to save that data in my form...i don't know how to do it...please any one can teach me to do that ...
thank you

Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#2: Apr 10 '07

re: How to save text data in my programme


Quote:

Originally Posted by sirimanna

hi,
is any one can help me? i have create a form and it have 3 text boxes..and i want to type some data in that text boxes and when i click save button i want to save that data in my form...i don't know how to do it...please any one can teach me to do that ...

Open a text file, write the information into it, close the file.

There are two techniques you would be likely to use. (I'm going to assume you're using VB6 - you didn't say).
  • Simpler to code, but providing less functionality, is the use of the Open...Close and various related statements.
  • The FileSystemObject requires you to add Microsoft Scripting Runtime to your project (under Project | References), and takes a little more work. But it provides a lot more power to work with files, folders and drives.
For more information, you should look up the various statements (such as Open, Close, Get, Input # and so on) and the FileSystemObject in your documentation.
Newbie
 
Join Date: Apr 2007
Location: I live in Sri Lanka.
Posts: 21
#3: Apr 10 '07

re: How to save text data in my programme


sorry i can't understand...i'm using vb6 and can u please send cord's? and metod to how to do it...
thank u
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#4: Apr 10 '07

re: How to save text data in my programme


Quote:

Originally Posted by sirimanna

sorry i can't understand...i'm using vb6 and can u please send cord's? and metod to how to do it...
thank u

It would really be better if you read the documentation and explore this stuff. The main purpose of TheScripts is to provide help when programmers are stuck on a particular problem in their code. We're not a school.

Also, quite a lot of students come here and try to get copy-and-paste answers to homework and coursework assignments. Providing them doesn't help the student, and on occasion has actually gotten them into serious trouble with their teachers.

So, for many reasons, we try not to provide hand-holding at the beginner level. Sorry, but as you can see there are good reasons for this policy. And there are web sites out there which will provide basic tutorials, if you search for them. For that matter, if you use the search facility here on TheScripts, chances are good you will find what you're after anyway. I'm sure basic file access must have been discussed at various times.
Member
 
Join Date: Mar 2007
Posts: 50
#5: Apr 10 '07

re: How to save text data in my programme


Quote:

Originally Posted by sirimanna

hi,
is any one can help me? i have create a form and it have 3 text boxes..and i want to type some data in that text boxes and when i click save button i want to save that data in my form...i don't know how to do it...please any one can teach me to do that ...
thank you

hello,
befofe using the code add reference from Project--->reference
"Microsoft Scripting Runtime"
Expand|Select|Wrap|Line Numbers
  1. Dim fsys As New FileSystemObject
  2. Dim Txtfl As TextStream
  3.  
  4.  Set Txtfl = fsys.CreateTextFile(app.path & "\"  & "CAADVREG.txt", True)
  5. Txtfl.WriteLine text1.text
  6. Txtfl.WriteLine text2.text
  7. Txtfl.WriteLine tex3.text
  8. txtfl.close
  9.  
Newbie
 
Join Date: Apr 2007
Posts: 2
#6: Apr 10 '07

re: How to save text data in my programme


I read this on another site, and I think it works

Declarations:
Expand|Select|Wrap|Line Numbers
  1. Private myString As String
To Retrieve Data:
Expand|Select|Wrap|Line Numbers
  1. myString = GetSetting("myApp", "Settings", "myString", vbNullString)
  2. Textbox1.Text = myString
  3. myString = GetSetting("myApp", "Settings", "myString2", vbNullString)
  4. Textbox2.Text = mystring
  5. myString = GetSetting("myApp", "Settings", "myString*and so on*", vbNullString)
  6. Textbox3.Text = mystring
To Set Data:
Expand|Select|Wrap|Line Numbers
  1. myString = Textbox1.Text
  2. SaveSetting "myApp", "Settings", "myString", myString
  3. myString = Textbox2.Text
  4. SaveSetting "myApp", "Settings", "myString2", myString
  5. myString = Textbox3.Text
  6. SaveSetting "myApp", "Settings", "myString*and so on*", myString
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#7: Apr 11 '07

re: How to save text data in my programme


Quote:

Originally Posted by evank3

I read this on another site, and I think it works
...

I think you will find that the SaveSetting and GetSetting funtions are for reading and writing values in the Registry. As such, they probably should be used with some care, and preferably after reading the documentation.
Reply