Support Forums
What's wrong with this? - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: What's wrong with this? (/showthread.php?tid=24432)



What's wrong with this? - Sam - 01-09-2012

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.


RE: What's wrong with this? - AceInfinity - 01-09-2012

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"


RE: What's wrong with this? - Sam - 01-09-2012

Not sure what you mean. I have 4 forms, this section of code is for 1 button on 1 of the forms.


RE: What's wrong with this? - AceInfinity - 01-09-2012

Where exactly does it break then? Can you show the error or provide all the code you have?


RE: What's wrong with this? - Sam - 01-09-2012

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/


RE: What's wrong with this? - AceInfinity - 01-09-2012

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.


RE: What's wrong with this? - Sam - 01-09-2012

I just realized that myself. I removed the catch from unclock.vb and it worked.


RE: What's wrong with this? - AceInfinity - 01-09-2012

At least you finally figured it out then lol Smile Nice


RE: What's wrong with this? - Sam - 01-09-2012

Not sure why it was even there but yeh its solved now.