Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's wrong with this?
#1
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.
Reply
#2
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"
Reply
#3
Not sure what you mean. I have 4 forms, this section of code is for 1 button on 1 of the forms.
Reply
#4
Where exactly does it break then? Can you show the error or provide all the code you have?
Reply
#5
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/
Reply
#6
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.
Reply
#7
I just realized that myself. I removed the catch from unclock.vb and it worked.
Reply
#8
At least you finally figured it out then lol Smile Nice
Reply
#9
Not sure why it was even there but yeh its solved now.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)