Jump to content

Saving Help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
PascalPro

PascalPro

    Newbie

  • Members
  • PipPip
  • 13 posts
I am creating a program where I need to save the text in both a rtb and normal textbox. Here is my save and open code as of now:

Save:
SaveFileDialog1.Filter = "txt (*.txt)|*.text"
        SaveFileDialog1.ShowDialog()
        If SaveFileDialog1.FileName <> "" Then
            FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
            PrintLine(1, Document.Text)
            FileClose(1)
        End If
Open:
Dim AllText As String = "", LineOfText As String = ""
        OpenFileDialog1.Filter = "txt (*.txt)|*.txt"
        OpenFileDialog1.ShowDialog()
        If OpenFileDialog1.FileName <> "" Then
            Try
                FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
                Do Until EOF(1)
                    LineOfText = LineInput(1)
                    AllText = AllText & LineOfText & vbCrLf
                Loop
                Document.Text = AllText
            Catch
            Finally
                FileClose(1)
            End Try
        End If
The code is really basic. I have one SaveFileDialoug and one OpenFileDialouge. Everytime I try to save my document it only saves one box. How can I make it save all boxes? Do I need file type other than .txt, or is that sufficiant. Do I need more dialouges? Any help would be appriciated. If you need any more information just ask.

Edited by WingedPanther, 10 November 2008 - 02:28 PM.
add code tags


#2
PascalPro

PascalPro

    Newbie

  • Members
  • PipPip
  • 13 posts
Update!

I have toyed around with the code a bit and I can now save the code in both the textbox and rtb. Now the problem is opening it. It always pastes the saved text in one box. So if I save "help" in the textbox and "help" in the rtb it will open as "help help" in one box. I can change the box but I can't seem to seperate the two "help"s. Here is my new save code:


 SaveFileDialog1.Filter = "txt (*.txt)|*.text"

        SaveFileDialog1.ShowDialog()

        If SaveFileDialog1.FileName <> "" Then

            FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)

            PrintLine(1, Document.Text)

            PrintLine(2, student.Text)

            FileClose(1)

        End If


document.text is the rtf and student.text in the textbox. The open code:


Dim AllText As String = "", LineOfText As String = ""

        OpenFileDialog1.Filter = "txt (*.txt)|*.txt"

        OpenFileDialog1.ShowDialog()

        If OpenFileDialog1.FileName <> "" Then

            Try

                FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)

                Do Until EOF(1)

                    LineOfText = LineInput(1)

                    AllText = AllText & LineOfText & vbCrLf

                Loop

                Document.Text = AllText

            Catch

            Finally

                FileClose(1)

            End Try

        End If

Help!

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Are you saving them to separate files?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
PascalPro

PascalPro

    Newbie

  • Members
  • PipPip
  • 13 posts
No, one file that saves text from 2 boxes and puts them back in the same boxes. I can only get it to deposit in one.

Edited by PascalPro, 11 November 2008 - 04:39 PM.
To make it more clear


#5
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
Define a separation sequence, possibly something like "]|separation|["
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#6
PascalPro

PascalPro

    Newbie

  • Members
  • PipPip
  • 13 posts
I'm new, where would the seperations in my code? Code is in posts 1 and 2.

#7
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
Not in the code. I mean that when you save it, output a special separation string, and when you read it, search each line for the separation string, then when you find it, put the rest of the input into the second text box (I'm not too familiar with VB, but any language providing decent string-handling functionality can do this. Hell, I can do it in C.)
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz