Support Forums

Full Version: What's wrong with this?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The error I'm getting is ('Catch' cannot appear outside of a 'Try' statement)

It looks to me like it isn't...

Code:
Public Class Form1

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            If TextBox1.Text = TextBox2.Text Then
                Me.Hide()
                black.Show()
                My.Settings.Password = TextBox2.Text
            Else
                MessageBox.Show("Passwords do not match!")
            End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub
End Class
VB, 2010 if you're wandering.
Is this all of your code? What does it say in the stack trace when you get this error? Do you have any other Try Catch statements? And also try going to your build menu, "Clean Solution", "Rebuild"
Not sure what you mean. I have 4 forms, this section of code is for 1 button on 1 of the forms.
Where exactly does it break then? Can you show the error or provide all the code you have?
That is all the code, the other forms I've just designed and haven't put any code on yet.

This is the error screenshot.

http://imageshack.us/photo/my-images/502/errorhlc.png/
What's inside Unlock.vb which isn't posted?

Edit: I'm assuming you finally fixed it now that you're just cruising on the Who's Online page? Smile

It doesn't mention Form1.vb for the error though, so if you are still dealing with this problem, you're looking in the wrong file.
I just realized that myself. I removed the catch from unclock.vb and it worked.
At least you finally figured it out then lol Smile Nice
Not sure why it was even there but yeh its solved now.