Statement is not valid in a namespace site

i'm an amateur programming, and it's my 1st project!! 
But the thing is I am having a problem . In error list it says "Statement is not valid in a namespace
Need advise what to do with this error

i'm an amateur programming, and it's my 1st project!! 
But the thing is I am having a problem . In error list it says "Statement is not valid in a namespace "
Need advise what to do with this error
You need to learn the structure of a program. You can not just place code willy nilly anywhere and think that will work.
Also you need to know what code can go where also. That will take time too. The information below is from the second link below. But when you read it you need to realize the difference in methods used by a console application and most other project styles.
So if you are unaware of that you may end up not understanding why certain information is not necessary for a Windows Forms app while other information is not necessary for a console app.
For example the Main Procedure I see used in console apps. In Windows.Forms apps not so much except for possibly extremely old VB.Net code and mostly I would have to guess by people who used to write console apps all the time then tried Windows.Forms apps
and for whatever reason couldn't refrain from using console app procedures in Windows.Forms apps which is unecessary and in my opinion quite confusing.
TutorialsPoint - VB.Net - Program Structure
Structure of a Visual Basic Program
File-Level Programming Elements              
When you start a project or file and open the code editor, you see some code already in place and in the correct order. Any code that you write should follow the following sequence:
Option                  
statements
Imports                  
statements
Namespace                  
statements and namespace-level elements
If you enter statements in a different order, compilation errors can result.
A program can also contain conditional compilation statements. You can intersperse these in the source file among the statements of the preceding sequence.
Option Statements                  
Option                  
statements establish ground rules for subsequent code, helping prevent syntax and logic errors. The
Option Explicit Statement (Visual Basic) ensures that all variables are declared and spelled correctly, which reduces debugging time. The
Option Strict Statement helps to minimize logic errors and data loss that can occur when you work between variables of different data types. The
Option Compare Statement specifies the way strings are compared to each other, based on either their
Binary or Text values.
Imports Statements                  
You can include an Imports Statement (.NET Namespace and Type) to import names defined outside your project. An
Imports statement allows your code to refer to classes and other types defined within the imported namespace, without having to qualify them. You can use as many
Imports statements as appropriate. For more information, see
References and the Imports Statement (Visual Basic).
Namespace Statements                  
Namespaces help you organize and classify your programming elements for ease of grouping and accessing. You use the
Namespace Statement to classify the following statements within a particular namespace. For more information, see
Namespaces in Visual Basic.
Conditional Compilation Statements                  
Conditional compilation statements can appear almost anywhere in your source file. They cause parts of your code to be included or excluded at compile time depending on certain conditions. You can also use them for debugging your application, because conditional
code runs in debugging mode only. For more information, see Conditional Compilation in Visual Basic.
Namespace-Level Programming Elements              
Classes, structures, and modules contain all the code in your source file. They are
namespace-level elements, which can appear within a namespace or at the source file level. They hold the declarations of all other programming elements. Interfaces, which define element signatures but provide no implementation, also appear at module
level. For more information on the module-level elements, see the following:
Class Statement (Visual Basic)                  
Structure Statement                  
Module Statement                  
Interface Statement (Visual Basic)                  
Data elements at namespace level are enumerations and delegates.
Module-Level Programming Elements              
Procedures, operators, properties, and events are the only programming elements that can hold executable code (statements that perform actions at run time). They are the
module-level elements of your program. For more information on the procedure-level elements, see the following:
Function Statement (Visual Basic)                  
Sub Statement (Visual Basic)                  
Declare Statement                  
Operator Statement                  
Property Statement                  
Event Statement                  
Data elements at module level are variables, constants, enumerations, and delegates.
Procedure-Level Programming Elements              
Most of the contents of procedure-level elements are executable statements, which constitute the run-time code of your program. All executable code must be in some procedure (Function,
Sub, Operator, Get,
Set, AddHandler, RemoveHandler,
RaiseEvent). For more information, see Statements in Visual Basic.
Data elements at procedure level are limited to local variables and constants.
The Main Procedure              
The Main procedure is the first code to run when your application has been loaded.
Main serves as the starting point and overall control for your application. There are four varieties of
Main:
Sub Main()
Sub Main(ByVal cmdArgs() As String)
Function Main() As Integer
Function Main(ByVal cmdArgs() As String) As Integer
The most common variety of this procedure is Sub Main(). For more information, see
Main Procedure in Visual Basic.
La vida loca

Similar Messages

  • If statement is not validating properly in JSP

    Actually i'm new to Java..
    The problem is when i take the parameter from another file which is an empty text box and i submit that. In the next jsp file i'am taking this value using getParameter("xxxx").
    if i send the empty or some value to this parameter, the if statement is not validating properly.
    here is my code in jsp....
    <%
    String bgcolor = request.getParameter("bgColor");
    out.println("Background Color = " + bgcolor);
    if (bgcolor == null)
    out.println("Hello Null");
    else
    out.println("Hello Not Null");
    %>
    Thanks in advance
    Kumar

    Hey there, you should know that Strings in Java are
    different from other types like int and double for
    example. Strings are objects so you cant check em
    with == but with the standard method .equals This is true but is not the problem here.
    @OP null and an empty length string are NOT the same thing. You probably want a check like
    if(bgColor.length()<1)And you might want to trim the String first to get rid of whitespace.

  • HT201210 I backed up old phone to PC then did a sync to new 4S but when trying to update apps on phone it states - account not valid in Argentine store, must switch to U.S. store. I am in US and when I view account on PC it correctly shows me in US. Now w

    I backed up old phone to PC then did a sync to new 4S but when trying to update apps on phone it states - account not valid in Argentine store, must switch to U.S. store. I am in US and when I view account on PC it correctly shows me in US. Now what?

    log out and log back in again to store
    and if required
    http://support.apple.com/kb/HT1311

  • The SQL statement is not valid - when importing data from SQL Server using a query

    Hi there,
    I am trying to import data from SQL to Power Pivot using a SQL query like below:
    SELECT Score.FieldCount, Score.Record.GetAt(0), Score.Record.GetAt(1),  Score.Record.GetAt(2),  Score.Record.GetAt(3),  Score.Record.GetAt(4)
    FROM 
    SELECT * FROM dbo.CLR1(
    dbo.CLR2('c:\FILES\Test.xml'), 
    'SELECT * FROM [dbo].[CXCustomer_Small]') Input
    ) Score
    And when I tried to validate it, it returns
    The SQL statement is not valid. A column name cannot be blank.
    I ran the above SQL statement in Management Studio and it works without problem. Any idea?
    Thanks!
    Chu
    -- Predict everything. http://www.predixionsoftware.com

    Never mind, I figured out - I need to give each column a name.
    -- Predict everything. http://www.predixionsoftware.com

  • Site behind load balancer - Key not valid for use in specified state

    Hi,
    I have created a sharepoint application page to access an active end point on ADFS and establish a fedauth session. All works well in single server. But when the page runs behind load balancer with 2 servers, it fails with key not valid for use in specified
    state exception. Stickiness is enabled on load balancer. verified that.
    I had made few changes to config file in microsoft.identitymodel section to accomodate adfs custom login. This included removing securitytokenhandlers and issuertokenresolvers as well. Is this impacting the encryption/decryption in anyway?
    Any pointers would help.
    Reference point for my application page : http://blog.helloitsliam.com/Lists/Posts/Post.aspx?ID=76

    Hi,
    As I understand, you encountered the error “Key not valid for use in specified state” when ADFS custom login.
    In order to run in Windows Azure Web Sites a Web application which uses WIF for handling authentication, you must change the default cookie protection method (DPAPI, not available on Windows Azure Web Sites) to something that will work in a farmed environment
    and with the IIS’ user profile load turned off.
    1. If you are using the Identity and Access Tools for VS2012, just go to the Configuration tab and check the box “Enable Web farm ready cookies”.
    2. If you want to do things by hand, add the following code snippet in your system.identitymodel/identityConfiguration element:
       <securityTokenHandlers>
         <add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, 
                 System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler,
                System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </securityTokenHandlers>
    There is a similar case:
    http://stackoverflow.com/questions/19323287/key-not-valid-for-use-in-specified-state-error-for-net-4-5-mvc-4-application
    Best regards,
    Sara Fan
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • The URL is not valid and cannot be loaded. This statement comes up on almost any attempt to log into or click a link to anything at least on 2 tries, then the site comes up. what's up with this?

    firefox v 3.6.13 is what I use. If I select something from "read Later" or a link from the home page to another site, I get that message - The URL is not valid and cannot be loaded. in a box that pops us a couple of times, then the site I want.

    Please [https://bugzilla.mozilla.org/show_bug.cgi?id=713167 see this.] Installing [https://www.microsoft.com/download/en/details.aspx?id=5638 Visual C++ 2005 SP1] or the .Net Framework 3.5 SP1 may help mitigate the issue.

  • Reporting Service Integration mode and Key not valid for use in specified state

    I had to uninstall SharePoint Foundation 2013 and reinstall it.
    What I have done:
    I uninstalled SharePoint and after that I removed all databases.
    I reinstalled SharePoint Foundation 2013 and it completed without errors.
    Everything else is working, except SSRS in Sharepoint Integrated Mode.
    If I check Central Administration - Manage services on server, I can found out that SQL Server Reporting Service Service is
    "Started". But if I try to create new service application (SQL Server Reporting Services Service Application), it gives me an error message:
    "Key not valid for use in specified state. (Exception from HRESULT: 0x8009000B)"
    I uninstalled SSRS in Sharepoint Integrated Mode and I reinstalled it but problems exists.
    It seems that "Encryption Keys" cause this problem.
    https://support.microsoft.com/kb/955757
    https://msdn.microsoft.com/en-us/library/ms156010%28v=sql.110%29.aspx
    I tried to Re-create Encryption Keys and Delete keys, but its not working either. It gives me only error message that:
    "Unable to locate the Reporting Server Windows service for instance MSSQLSERVER."
    I don't have any reporting server databases, because I removed all
    databases when I uninstalled SharePoint. Also I don't have Encryption
    Keys backups.
    I have found several similar question but no answer, example here:
    https://social.technet.microsoft.com/Forums/ie/en-US/df02dc05-5ce8-499d-9ba3-ab392a5fc3af/sharepoint-2013-ssrs-application-error-key-not-valid-for-use-in-specified-state-exception?forum=sharepointdevelopment
    Any ideas how I can fix this problem?

    Hi,
    From the Reporting Server Configuration Manager you have to restore the encryption key.
    Please try to delete databases(reportserver & reportservertempdb) and delete the reportserver and reports site on IIS. Then you have to start over the configuration again.
    If the issue still exists, Please check ULS log to see if anything unexpected occurred.
    For SharePoint 2013, by default, ULS log locates in
    "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS"
    More information about SQL Reporting services Installation with SharePoint 2013 for your reference:
    http://expertsharepoint.blogspot.de/2014/03/sql-reporting-services-installation.html
    Best Regards,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • WCF Service update UPS. Operation is not valid due to the current state of the object.

    I try import custom data to custom user properties from my own wcf service (on sharepoint server machine), but i got
    Message "Operation is not valid due to the current state of the object. "
    on line
    userProfile[PropertyConstants.Department].Value = "SDDDD";
    Why i cant modify property value?
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite site = new SPSite("http://portal.local"))
    SPServiceContext serviceContext = SPServiceContext.GetContext(site);
    using (var web = site.OpenWeb())
    Debug.WriteLine(web.CurrentUser); //Here AppPoolAccount user of current wcf service
    Debug.WriteLine(WindowsIdentity.GetCurrent().Name); //Here too AppPoolAccount user of current wcf service
    UserProfileManager userProfileMgr = new UserProfileManager(serviceContext);
    ProfilePropertyManager profilePropMgr = new UserProfileConfigManager(serviceContext).ProfilePropertyManager;
    ProfileSubtypePropertyManager subtypePropMgr = profilePropMgr.GetProfileSubtypeProperties("UserProfile");
    UserProfile userProfile = userProfileMgr.GetUserProfile(accountName);
    userProfile[PropertyConstants.Department].Value = "SDDDD";
    userProfile.Commit();
    My service running under domain\SPSvcAcc what have full permissions on UPS service, it's management account and UPS admin with full rights.
    If i create console app with identical code and run it under SPSvcAcc account it working without problems
    What i do wrong?

    Hi,
    pls seee if you can add threading like this below to solve the pbm
    https://social.technet.microsoft.com/Forums/office/en-US/b6d6f85c-e12b-4540-a821-690e296b7b56/operation-is-not-valid-due-to-the-current-state-of-the-object-exception-when-activating-a?forum=sharepointdevelopmentprevious
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Key not valid for use in specific state". Number o...

    Skype died and cannot reinstall. error message key not valid for use in specific state". Number of error is 1603. I have seen the solutions posted on this and other sites, but they are rather daunting for a non tec person. Will Skyp/Windows be providing a solution any time soon? Or is it easier to use an alternative .
    M
    Solved!
    Go to Solution.

    Download and run the following program:
    http://community.skype.com/t5/Windows-desktop-client/Upgrade-causes-Error-1603/m-p/3667341/highlight...
    REBOOT then try to reinstall the latest version of Skype.

  • Outlook 2013 - Password change breaks S/MIME Certs "An error occurred in the underlying security system. Key not valid for us in specified state."

    AD password change comes up, user changes password.
    Tries to send signed or encrypted email with a Comodo S/MIME certificate, and gets the following error:
    ""An error occurred in the underlying security system.  Key not valid for us in specified state."
    I now have two reports of this error - one on Windows 7, and one on Windows 8.0 (remote user).
    The one on Windows 8.0, we tried removing their S/MIME cert from Outlook/Windows and re-adding, this did NOT resolve the issue.
    Plan was originally to have the 8.0 user ship their machine in, and wipe it, since nothing else could fix it and I wasn't finding anyone else with the same issue.  Now that I've got a second user with the same issue, its looking like a bug/issue and
    not a random glitch.
    Thanks in advance for any and all help with this!

    Hi,
    Thank you for your question.
    I am trying to involve someone familiar with this topic to further look at this issue.
    Thanks,
    Melon Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • ERROR: "key not valid for use in specified state" when updating to Lightroom 5.6 in Win8.1

    While doing a routine update from Lightroom 5.5 to v5.6 in Win 8.1, the installation halted at the start of the installation with the vague error message, "key not valid for use in specified state".  Although v5.5 was working just fine, the install routine deleted the v5.5 application files.  I rolled back to the previous system restore point (set just prior to the install) and recovered the executable files.  However, now the 5.5 files won't open the default catalog, none of the backups, or even create a new catalog.
    As v5.x was purchased as an update to v4.x, I've tried to reinstall the original Lightroom v4.x app from the factory disk.  I get the same error.
    Suggestions?
    Thanks. Dan

    I have a similar problem to Dan. while doing a routine upgrade from Lightroom 5.5 to 5.6 I got the
    : "key not valid for use in specified state"
    error and now Lightroom has completely disappeared. I've tried to uninstall, but there is nothing to uninstall. Going back to try to install the original 5.4 just results in the same error.
    A problem may have been that I closed Lightroom when the upgrade started to download. It then re-opened again when the install was halfway through., I assumed that was an error and closed it. just after that the error first appeared in the installer.
    I still had an older version of lightroom 4 installed. I've uninstalled it, and that didn't make any difference.
    I've also tried removing anything in the registry left over from the old installs and that didn't help either.
    Any suggestions?
    CHeers, Angus

  • Error occurred in deployment step 'Add Solution': Operation is not valid due to the current state of the object

    hi,
      when i was trying to deploy a SP  solution from my vs 2012 solution. this error  is displayed.
    i tried many things like
    1) get the wsp and apply power shell cmds to add and deploy, here also it failed:
    Add-SPSolution -LiteralPath d:\mywsp.wsp
    Install-SPSolution mywsp.wsp -GacDeployment -AllWebApplications -Local
    2) restart the timer services and  do  iisreset and  reboot the server. etc .as mentioned in one of the  the below  blogs:
    http://sharepoint1on1.blogspot.in/2014/04/sharepoint-error-occurred-in-deployment.html
    http://suehernandez.wordpress.com/2011/03/31/error-occurred-in-deployment-step-activate-features-operation-is-not-valid-due-to-the-current-state-of-the-object/
    http://www.dotnetsharepoint.com/2014/04/error-occurred-in-deployment-step-add.html
    http://social.msdn.microsoft.com/Forums/en-US/63adde23-03cf-4b65-923e-1219da94a780/error-occurred-in-deployment-step-add-solution-operation-is-not-valid-due-to-the-current-state-of?forum=sharepointdevelopmentprevious
    http://www.shakirmajeed.com/error-occurred-in-deployment-step-activate-features-operation-is-not-valid-due-to-the-current-state-of-the-object/
    but even after doing all these steps, the  error still persists!. and am not deploying into a remote server, the dev env is in a VM, where sp 2013, vs 2012, sql 2012  are installed.
    just wanna share one  note:   there is a isue in my search admin component. index was reset due to some reason. and from that time onwards my search full/incremental crawls were not working!
    will this cause an issue in my wsp deployment ? i hope  it wont, still  asking...
    can anyone help me how to resolve this error.because this is a  show stopper for me for the last few days!
    help is highly appreciated!

    This issue cause because of feature activation failure while WSP deployment.
    when you create a WSP using visual studio, it creates WSP package with default deployment configuration settings.
    Please restrict feature activation configuration, this will help you to troubleshoot this issue.
    - Click on Project in WSP and press F4, it will open "Project Properties"
    - set "Active deployment Configuration" - as "No Activation"
    - you can activate this features in required sequence after deployment using Activate-SPFeature
    If my contribution helps you, please click Mark As Answer on that post and Vote as Helpful
    Thanks, ShankarSingh(MCP)

  • Error_27_Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object.

    I created a SharePoint 2013 farm solution project in Visual Studio 2013 (running on the same machine where SharePoint 2013 server is running) with
    event receiver.  I added web.config at project root level to store connection string (I'm working off external SQL DB) and got the following error during deployement:
    Error 27
    Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object.
    When I commented out the ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString; the error went away.  Am I missing something or not supposed to add my own App.config to SharePoint project solution? 

    Hi,
    From your description, you might want to store your connection string in web.config and there is an error during deployment.
    It is recommended to store the configuration data of SharePoint solution in either property bags or hierarchical object store.
    The links below will provide more information about this:
    http://blogs.msdn.com/b/zwsong/archive/2012/03/27/where-should-you-store-your-sharepoint-solution-s-configuration-data.aspx
    http://msdn.microsoft.com/en-us/library/ff647766.aspx
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they
    help and unmark them if they provide no help. If you have feedback for TechNet
    Subscriber Support, contact [email protected]
    Patrick Liang
    TechNet Community Support

  • A Linux version fo Mozilla Firefox 6 Start Page states "The URL is not valid and cannot be loaded." - Why?

    Hi, My Linux Mint (a Debian/Ubuntu flavor) when first seen, the Mozilla Firefox 6 Start Page was great. However, when moving away to other sites and then clicking home the response was Alert - "The URL is not valid and cannot be loaded." Having trying everything (apart from using a large club!) I am lost. Any suggestions team? Mark

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    See also:
    * https://support.mozilla.com/kb/How+to+set+the+home+page - Firefox supports multiple home pages separated by '|' symbols
    * http://kb.mozillazine.org/Preferences_not_saved

  • Sometimes when firefox loads a web page the error message comes up stating The URL is not valid and cannot be loaded. And I know this is a valid web site. What gives?

    This happens very often. When I open Mozilla sometimes I get an error stating that "The URL is not valid and cannot be loaded." When I click ok the site stops loading and the tab is titled untiled.

    This can be a problem with DDE.<br />
    See http://kb.mozillazine.org/Windows_error_opening_Internet_shortcut_or_local_HTML_file_-_Firefox

Maybe you are looking for

  • Generate schedule lines via MRP

    Hi, Unable to generate schedule lines via MRP. Settings: Mat master - External proc , no spl proc OA - Maintained Source list - Maintained MRP Relevant - Indicator 2 Quota arrangement- Exist with only 1 vendor(same as of OA) 100% MD03 - Planning data

  • Power Mac G4 RAID Question

    After successfully putting OS X Leopard on my Power Mac G4, I then gasped at the amount of space I had; from the built in 10 GB hard drive, I had a couple hundred MegaBytes left. However, I recently pulled a 40 GB Hard Drive from another computer, an

  • Adobe Story Problems

    Hello, all I want is for my Adobe Story app to work, for some reason I keep getting this error message "The application cannot be installed due to a certificate problem. The certificate does not match the installed application certificate, does not s

  • Photoshop CC, the program, shutdown directley

    photoshop CC, the program, shutdown directley. How can I run photoshop cc without shutingdown?

  • (  jrew.exe encounterd problem,help needed  )

    MY DEARS I AM FACING A PROBLEM ON MY P4 LAPTOP AND DESKTOP COMPUTOR ON A PRGRAMM ON SURGERY CD ,WHICH ON START UP DIPLAYS MESSAGE ( jrew encountered a problem,needs to close-) WHAT IS THE SOLUTION .HELP IS APPERECIATED. MANY REGARDS FOR HELPER. DR QA