Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Odd error in VB 2008

Name: Anonymous 2012-10-17 12:26

Private Sub btnName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnName.Click
        Dim stream As New System.IO.FileStream(recipes, IO.FileMode.Open, IO.FileAccess.Read)
        Dim recipefound As Boolean = False
        Dim oreader As New System.IO.StreamReader(stream)
        'Sets up the streamwriter to append to the text file.
        'Also declares a variable for testing if recipe already exists.

        If txtrecipe.Text = "" Or txtservings.Text = "" Then
            MsgBox("You haven't filled in all of the textboxes.")
            'If there are empty textboxes (Servings and Recipe name), an
            'error message is produced.
            Do Until oreader.Peek() <> -1 Or recipefound = True
                If oreader.ReadLine.Contains(txtrecipe.Text) Then
                    recipefound = True
                End If
            Loop
            'Until it reaches the end of the file, or if the recipe is found
            'there is a loop, checking to see if the recipe exists.
            If recipefound = True Then
                MsgBox("Recipe already exists")
            End If
        End If
        oreader.Dispose()
        stream.Dispose()
        If recipefound = False Then
            Dim stream As New System.IO.FileStream(recipes, IO.FileMode.Append)
            Dim owriter As New System.IO.StreamWriter(stream)
            owriter.WriteLine(txtrecipe.Text)
            owriter.WriteLine(txtservings.Text)
            MsgBox("Recipe name entered, please enter the rest of the recipe data.")
            btnName.Enabled = False
            btnIngredient.Enabled = True
            owriter.Dispose()
            'Write the Recipe name on a line and then the servings on
            'another. Confirms it through a message box, and disables
            'the use of the name button, enabling the ingredient adding one.
            stream.Dispose()
            owriter.Dispose()
        End If
    End Sub

In the final if statement, the stream variable 'hides a variable in an enclosing block'. I'm using VB 2008 and wondered if I could get a hand with this.

Name: Anonymous 2012-10-17 12:35

bump

Name: Anonymous 2012-10-17 12:41

>>2
Fuck off, faggot.

Name: sage 2012-10-17 20:29

>asking for legitimate programming help on /prog/
>coding in visual basic
I scrappy doo

Don't change these.
Name: Email:
Entire Thread Thread List