locked
"Statement is not valid in a namespace" Help?

    Question

  • Could someone help me with the problem i am having?

    I am trying to make a simple program but i keep getting a "Statement is not valid in a namespace" error, And when i try to go indent it and such. It will not let me, but instead just going back to the way it was.

    Could someone help me? :(

    Thanks ;D
    Thursday, August 20, 2009 12:40 PM

Answers

  • Is this code *after* the line that says:

    Public Class Form1

    and *before* the line that says

    End Class?

    Also, if you use the </> button on the toolbar of your post you can better format your code.

    Hope this helps.
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Marked as answer by Bobbahbrown Thursday, August 20, 2009 4:03 PM
    Thursday, August 20, 2009 3:22 PM
  • Public Class Form1
       Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
       End Sub 
    
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    
          WebBrowser1.Navigate(Button1.Tag)
    
       End Sub
    End Class
    Is this what your code looks like?

    All code for Form 1, should be in the same class (called Form1).  If outside that class, Import statements and other "global data" is kept.
    Mark the best replies as answers. Closing out your old/answered questions, will give us more time to answer your active questions.
    • Marked as answer by Bobbahbrown Thursday, August 20, 2009 4:21 PM
    Thursday, August 20, 2009 4:08 PM

All replies

  •  There is no way we can tell you without the code.  show us the code you try to use, then we can tell you the namespace it belongs to.

    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    Thursday, August 20, 2009 1:23 PM
  • you might be declare some variable outside the class declaration.

    e:g

    Dim str As Sring

    Public Class Form1

    End Class

    you should move that variable inside the Class

    Public Class Form1

    Dim str As String

    End Class


    Asgar
    Thursday, August 20, 2009 3:09 PM
  •  There is no way we can tell you without the code.  show us the code you try to use, then we can tell you the namespace it belongs to.

    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on

    This is the code that i am having the error with... Also, To inform you im using the tag of the button to set the URL of the webbrowser.

    Private

     

    Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End

     

    Sub

    Private

     

    Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    WebBrowser1.Navigate(Button1.Tag)

    End

     

    Sub

    Thursday, August 20, 2009 3:17 PM
  • This is the code...


    Private

     

    Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End

     

    Sub

    Private

     

    Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    WebBrowser1.Navigate(Button1.Tag)

    End

     

    Sub

    Thursday, August 20, 2009 3:18 PM
  • Is this code *after* the line that says:

    Public Class Form1

    and *before* the line that says

    End Class?

    Also, if you use the </> button on the toolbar of your post you can better format your code.

    Hope this helps.
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Marked as answer by Bobbahbrown Thursday, August 20, 2009 4:03 PM
    Thursday, August 20, 2009 3:22 PM
  • No it isent... Q.Q
    Thursday, August 20, 2009 4:02 PM
  • Public Class Form1
       Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
       End Sub 
    
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    
          WebBrowser1.Navigate(Button1.Tag)
    
       End Sub
    End Class
    Is this what your code looks like?

    All code for Form 1, should be in the same class (called Form1).  If outside that class, Import statements and other "global data" is kept.
    Mark the best replies as answers. Closing out your old/answered questions, will give us more time to answer your active questions.
    • Marked as answer by Bobbahbrown Thursday, August 20, 2009 4:21 PM
    Thursday, August 20, 2009 4:08 PM
  • Very helpful, I am on tutorial #2 of the VB.net tutorials making a maze. I type in the code over and over getting the same error, finally I typed the error into a search engine and found this answer right off the bat. I am totally new to this, both programming and forums someone who knows how to fix it might want to get it clarified in the tutorial.

     

    Thank You Very Much

    Redfire8869

    When one ceases to learn the journey is over, never stop learning.

    Monday, May 16, 2011 9:32 AM