How to save text data in my programme

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sirimanna
    New Member
    • Apr 2007
    • 21

    How to save text data in my programme

    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
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    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 FileSystemObjec t 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 FileSystemObjec t in your documentation.

    Comment

    • sirimanna
      New Member
      • Apr 2007
      • 21

      #3
      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

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        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.

        Comment

        • SanjuMtr
          New Member
          • Mar 2007
          • 47

          #5
          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"
          Code:
          Dim fsys As New FileSystemObject
          Dim Txtfl As TextStream
          
           Set Txtfl = fsys.CreateTextFile(app.path & "\"  & "CAADVREG.txt", True)
          Txtfl.WriteLine text1.text
          Txtfl.WriteLine text2.text
          Txtfl.WriteLine tex3.text
          txtfl.close

          Comment

          • evank3
            New Member
            • Apr 2007
            • 2

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

            Declarations:
            Code:
            Private myString As String
            To Retrieve Data:
            Code:
            myString = GetSetting("myApp", "Settings", "myString", vbNullString)
            Textbox1.Text = myString
            myString = GetSetting("myApp", "Settings", "myString2", vbNullString)
            Textbox2.Text = mystring
            myString = GetSetting("myApp", "Settings", "myString*and so on*", vbNullString)
            Textbox3.Text = mystring
            To Set Data:
            Code:
            myString = Textbox1.Text
            SaveSetting "myApp", "Settings", "myString", myString
            myString = Textbox2.Text
            SaveSetting "myApp", "Settings", "myString2", myString
            myString = Textbox3.Text
            SaveSetting "myApp", "Settings", "myString*and so on*", myString

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              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.

              Comment

              Working...