Results 1 to 2 of 2

Thread: Write and then Read Text

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Location
    Uk, Lancashire
    Posts
    21

    Question Write and then Read Text

    Hi wondered if any one could help me, my problem is im creating a windows application in vb 2005, there are 10 text box's where i need to save to one text file but i am inserting before the user enters any text a string variable which can be loaded in from flash dynamically :-

    Code:
     Try
                If System.IO.File.Exists(FILE_NAME7) And Mod7Header.Enabled = True Then
                    Dim objWriter As New System.IO.StreamWriter(FILE_NAME7)
                    objWriter.BaseStream.Seek(0, SeekOrigin.End)
                    objWriter.WriteLine("header7=" + ((Mod7Header.Text)) & ControlChars.CrLf)
                    objWriter.WriteLine("body7=" + ((Mod7MidText.Text)))
                    objWriter.Flush()
                    objWriter.Close()
    
                Else
                    'If Mod7Header.Text = "" Then
                    '    MsgBox("Module 7 Header Text has not been filled in")
                    'End If
                End If
            Catch ex As System.IO.IOException
            End Try
    you can see "header7=" and "body7=" this is so that the action script can load in the text to that specific variable.

    My problem is then loading in the text into there respective text box's inwhich they came from. i can filter the ("header7=" and "body7=") out by using this code:-

    Code:
    If System.IO.File.Exists(FILE_NAME7) = True Then
                Dim sr7 As New IO.StreamReader(FILE_NAME7)
                sr7.BaseStream.Seek(0, SeekOrigin.Begin)
                While sr7.Peek <> -1
                    TextLine7 = TextLine7 & sr7.ReadLine() & ControlChars.CrLf
                End While
                sr7.Close()
                Mod7Header.Text = TextLine7
                Mod7Header.Text = Mod7Header.Text.Replace("header7=", "")
            End If
    
            If System.IO.File.Exists(FILE_NAME7) = True Then
                Dim sr7b As New IO.StreamReader(FILE_NAME7)
                sr7b.BaseStream.Seek(0, SeekOrigin.Begin)
                While sr7b.Peek <> -1
                    TextLineB7 = TextLineB7 & sr7b.ReadLine()
                End While
                sr7b.Close()
                Mod7MidText.Text = TextLineB7
                Mod7MidText.Text = Mod7MidText.Text.Replace("body7=", "")
            End If
    the first text box loads in the text as it should but the second loads in the firsts and seconds text. How can i tell it to read in from the second line? i have tried limiting the first text box to 20 chars and then telling (sr7b.basestream.seek(20,seekorigin.begin) so that it miss's the first 20 chars but it just shows a blank line, how can i get around this any one have any ideas??

    Thanks in Advance

    Neil

  2. #2
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    Re: Write and then Read Text

    From what I understand in flash is that it reads it from one line, and it is like
    "header7=My Header&body7=My Body&.."
    then in the text fields in flash it reads the variables header7 and body7..

    not sure if it depends on the number of lines.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width