|
-
Aug 8th, 2003, 08:31 AM
#1
Thread Starter
New Member
Statement is Not a Valid Namespace
I am new to VB and VB.NET so be gentle.
I am trying to declare 2 global variables in the general declaration section of my code as follows:
Option Explicit On
Public Const gcstrServer As String = "Server" & vbLf _
Dim txtLogon As String = "MS Exchange Server"
--------------------------------------------------------------------------
This is giving me an error for both variable declarations:
"Statement is not a valid namespace"
What am I doing wrong? Any advice is much appreciated
Many Thanks
Mike Jones
-
Aug 8th, 2003, 08:35 AM
#2
you cant put that outside a class definition. This is not VB6 where there was no visible definitions for class. When you add a new class to your app, the class definition is added for you..
Public Class Class1
' Code in here
End Class
-
Aug 8th, 2003, 08:48 AM
#3
Thread Starter
New Member
Cheers Cander.
I am getting to grips with this slowly. I am originally a Java programmer trying to make the leap accross. Does that mean that if any variables that are declared in a public class are globally accessible making the general decs bit redundant.
Mike
-
Aug 8th, 2003, 08:53 AM
#4
They are only accessible to the class. But if you make the variables public, then you can access them outside the class using standard object oriented programming.
classname.variablename
VB.NET, except for syntax, follows much the same rules and skills as java does, so just keep that in mind.
-
Jul 20th, 2004, 11:16 PM
#5
Sleep mode
To extend your knowledge , you can do this :
VB Code:
Namespace mYnSpace
Public Enum a
i = 0
x = 2
End Enum
Public Delegate Sub Dlg()
Public Class Class1
'CODE HERE
End Class
End Namespace
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|