I know that title was complicated, i wasnt really sure what to call it.

Basically at the moment I have the code which opens values that are after words in a text file. (Thanks to Unhnd_Exception)

I have a text file, which lists all the stocks of all the fruit in a store. Id like to beable to open the amount of stocks into the form. Then save any edits there may be.

There is also things like "Favourite Fruit = Apples" in the text file aswell, which is why i need the code to open text aswell as numbers.

Code at the moment:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Importing Current into the application
        Dim SavePath As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\fruits.txt"
        Dim fStream As New System.IO.FileStream(SavePath, IO.FileMode.Open)
        Dim sReader As New System.IO.StreamReader(fStream)
        Dim line() As String

        Do While sReader.Peek > -1

            line = sReader.ReadLine.Split(New Char() {""""c}, StringSplitOptions.RemoveEmptyEntries)
            If line.Count <> 2 Then Continue Do 'wrong format
            If Not IsNumeric(line(1)) Then Continue Do 'wrong format

            Select Case line(0).Trim
                Case "apples"
                    apples.Text = line(1)
                Case "bananas"
                    bananas.Text = line(1)
                Case Else
                    'Bad Fruit
            End Select
        Loop

        fStream.Close()
        sReader.Dispose()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim SavePath As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\fruits.txt"
        Dim file As System.IO.StreamWriter

        file = My.Computer.FileSystem.OpenTextFileWriter(SavePath, True)
        file.WriteLine("apples" & " " & """" & apples.Text & """")
        file.WriteLine("bananas" & " " & """" & bananas.Text & """")

        file.Close()
        file.Dispose()

        MessageBox.Show("Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

End Class

Now I didnt realise at the time that it didnt open text, just numeric values.

Does anyone know what I can do to open text as well as numbers into a textbox.

just adjust the your text inputs to look like this:

Select Case line(0).Trim
Case "apples"
     apples.Text = line(1)
     apples2.text = line(0)
Case "bananas"
     bananas.Text = line(1)
     bananas2.Text = line(0)
Case Else
     'Bad Fruit
End Select

feed the textbox like so

AppleTextBox.Text = apples2.Text & " " & apples.Text

to save the info modify your output to look like this

file.WriteLine(AppleTextBox.Text)

Bump, zinnqu is too busy to help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.