Open and Save as .txt code in VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soramaster
    New Member
    • May 2007
    • 23

    Open and Save as .txt code in VB6

    I'm building Jetpad and I don't know the open or save code. Can someone please help me?

    thanks
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by soramaster
    I'm building Jetpad and I don't know the open or save code. Can someone please help me?

    thanks
    Let's see the code in action, soramaster!

    In what format do you intend to save this wonderful information?

    .txt, .mdb, etc...

    Comment

    • soramaster
      New Member
      • May 2007
      • 23

      #3
      Originally posted by Dököll
      Let's see the code in action, soramaster!

      In what format do you intend to save this wonderful information?

      .txt, .mdb, etc...

      I want it to be able to save it as .txt.

      I'm still working on the layout of my program.

      This is the stuff I have:
      This is the forms:
      1.frmWindow
      2.mdiMAIN

      This is what I have in frmWindow:
      1.txtTEXT "a text box"

      I have a menu in mdiMAIN

      Thanks for the help. If you need any other info let me know and I'll post it

      Comment

      • Dököll
        Recognized Expert Top Contributor
        • Nov 2006
        • 2379

        #4
        Originally posted by soramaster
        I want it to be able to save it as .txt.

        I'm still working on the layout of my program.

        This is the stuff I have:
        This is the forms:
        1.frmWindow
        2.mdiMAIN

        This is what I have in frmWindow:
        1.txtTEXT "a text box"

        I have a menu in mdiMAIN

        Thanks for the help. If you need any other info let me know and I'll post it
        Gotcha!

        Save the file to .txt in this fashion:

        Code:
        Open App.Path &"\usermate.txt" For Output As filenum1
        
        Open App.Path &"\usermate.txt" For Append As filenum1
        Read the file from .txt in this fashion:

        Code:
        Open App.Path &"\usermate.txt" For Input As filenum1

        Have fun!

        Dököll

        Comment

        • soramaster
          New Member
          • May 2007
          • 23

          #5
          Originally posted by Dököll
          Gotcha!

          Save the file to .txt in this fashion:

          Code:
          Open App.Path &"\usermate.txt" For Output As filenum1
          
          Open App.Path &"\usermate.txt" For Append As filenum1
          Read the file from .txt in this fashion:

          Code:
          Open App.Path &"\usermate.txt" For Input As filenum1

          Have fun!

          Dököll

          Ok I have Private Sub FS_Click(Index As Integer)
          Open App.Path & "\usermate. txt" For Output As filenum1

          Open App.Path & "\usermate. txt" For Append As filenum1
          End Sub

          FS ="
          File
          ...Save"

          I don't know if thats right. When I test it I get a "Run Time error '52': Bad file or number"

          I have VB6

          Did I put it in the wrong area?

          Comment

          • Dököll
            Recognized Expert Top Contributor
            • Nov 2006
            • 2379

            #6
            Originally posted by soramaster
            Ok I have Private Sub FS_Click(Index As Integer)
            Open App.Path & "\usermate. txt" For Output As filenum1

            Open App.Path & "\usermate. txt" For Append As filenum1
            End Sub

            FS ="
            File
            ...Save"

            I don't know if thats right. When I test it I get a "Run Time error '52': Bad file or number"

            I have VB6

            Did I put it in the wrong area?
            You're doing fine, you just need to add:

            Code:
            filenum1 = FreeFile
            Private Sub FS_Click(Index As Integer)
            Open App.Path & "\usermate.txt" For Output As filenum1
            Write #filenum1, Text1.Text 'this being container of text being loaded in usermate.txt
            Close #filenum1 ' in your code here to have it do what you want
            End Sub
            Last edited by Dököll; May 19 '07, 11:17 PM. Reason: Removed spacing

            Comment

            • soramaster
              New Member
              • May 2007
              • 23

              #7
              I add a toolbar to my program but how do I add the button images and stuff?

              Comment

              • Dököll
                Recognized Expert Top Contributor
                • Nov 2006
                • 2379

                #8
                Originally posted by soramaster
                I add a toolbar to my program but how do I add the button images and stuff?
                How do you mean?

                (1) Your ToolBox is equiped with both Image and PictureBox add ins
                (2) Looking up your Image, PictureBox properties, it's pretty standard

                Can you tell us a little more?

                Have a great week!

                Comment

                • soramaster
                  New Member
                  • May 2007
                  • 23

                  #9
                  Originally posted by Dököll
                  How do you mean?

                  (1) Your ToolBox is equiped with both Image and PictureBox add ins
                  (2) Looking up your Image, PictureBox properties, it's pretty standard

                  Can you tell us a little more?

                  Have a great week!
                  This is what I have and I don't have no buttons or images.

                  Code:
                   Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
                  End Sub

                  Comment

                  • soramaster
                    New Member
                    • May 2007
                    • 23

                    #10
                    Ok I figured out how to add the buttons but I can't add any images to them. How do I do that?

                    Comment

                    • soramaster
                      New Member
                      • May 2007
                      • 23

                      #11
                      Also I want it to a be able to store the info in the program too if the user selects that option and I want it password protected before you use the program I want it to be able to log the user in with the windows account. How would I be able to make that happen?

                      Comment

                      • Dököll
                        Recognized Expert Top Contributor
                        • Nov 2006
                        • 2379

                        #12
                        Originally posted by soramaster
                        Ok I figured out how to add the buttons but I can't add any images to them. How do I do that?
                        (1) Look your left, find your toolbox,

                        (2) if you do not have it there, look above your your screen, what looks to be a wrench and a hammer, click on it

                        (3) Choose PictureBox or Image

                        (4) Go to either the PictureBox or the Image properties
                        Clicking once on either will make avaialbel properties pane

                        (5) Find Image in the list, then hit that little button

                        (6) Find Photo form your files

                        Within your code for the command button that'll fire your Image, say:

                        Code:
                        'Set visivility to false when form loads
                        Private Sub Form_Load()
                        
                        Image1.Visible = False
                        
                        End Sub
                        
                        'Bring snapshot in as needed
                        
                        Private Sub MyPicButton_Click()
                        
                        Image1.Visible = True
                        
                        End Sub
                        
                        Or 
                        
                        Private Sub MyPicButton_Click()
                        
                        Picture1.Visible = True
                        
                        End Sub
                        
                        Depending on which control you are using..
                        But, there you have it. I did not try this, but it should work just fine. Please stay tuned if you do not understand.

                        Also, I would post you code if I were you, you'll find helpful hits/replies that way.

                        In a bit!

                        Comment

                        • soramaster
                          New Member
                          • May 2007
                          • 23

                          #13
                          Originally posted by Dököll
                          (1) Look your left, find your toolbox,

                          (2) if you do not have it there, look above your your screen, what looks to be a wrench and a hammer, click on it

                          (3) Choose PictureBox or Image

                          (4) Go to either the PictureBox or the Image properties
                          Clicking once on either will make avaialbel properties pane

                          (5) Find Image in the list, then hit that little button

                          (6) Find Photo form your files

                          Within your code for the command button that'll fire your Image, say:

                          Code:
                           
                          'Set visivility to false when form loads
                          Private Sub Form_Load()
                           
                          Image1.Visible = False
                           
                          End Sub
                           
                          'Bring snapshot in as needed
                           
                          Private Sub MyPicButton_Click()
                           
                          Image1.Visible = True
                           
                          End Sub
                           
                          Or 
                           
                          Private Sub MyPicButton_Click()
                           
                          Picture1.Visible = True
                           
                          End Sub
                           
                          Depending on which control you are using..
                          But, there you have it. I did not try this, but it should work just fine. Please stay tuned if you do not understand.

                          Also, I would post you code if I were you, you'll find helpful hits/replies that way.

                          In a bit!
                          Well I can't use the program anymore. Something happend and it says it can't find what it needs and it would not load. I tried to uninstall it but it says that the uninstaller is corrupted. So I deleted the VB files "Not the programs, I backed them up" and deleted the VB keys from the regedit and then it showed up as not installed so I clicked next to install and it comes up with an error and won't finish installing. I tried everything. IDK how to get it installed.

                          Comment

                          • Dököll
                            Recognized Expert Top Contributor
                            • Nov 2006
                            • 2379

                            #14
                            Originally posted by soramaster
                            Well I can't use the program anymore. Something happend and it says it can't find what it needs and it would not load. I tried to uninstall it but it says that the uninstaller is corrupted. So I deleted the VB files "Not the programs, I backed them up" and deleted the VB keys from the regedit and then it showed up as not installed so I clicked next to install and it comes up with an error and won't finish installing. I tried everything. IDK how to get it installed.
                            Geez! You must be unhappy...

                            Try restoring your machine to a date you did not have any problems, perhaps two weeks ago!

                            See what happens...

                            Comment

                            • soramaster
                              New Member
                              • May 2007
                              • 23

                              #15
                              Well its installed but after it starts I keep getting a compnent error is not corectly registerd and other errors.
                              after I did the restore

                              Comment

                              Working...