error BC30001: Statement is not valid in a namespace

Posted on 2011-10-12
Last Modified: 2012-08-14

This is from the codebehind on an aspx page. Environment is Visual Web Developer 2010 Express, IIS 7.

I'm trying to define a function for massaging time.  I'm getting:

error BC30001: Statement is not valid in a namespace.
Function dhRoundTime(dtmTime As Date, intInterval As Integer) As Date

Any help on what is wrong here?

Original code is from here:

Function dhRoundTime(dtmTime As Date, intInterval As Integer) As Date
    ' Round the time value in varTime to the nearest minute
    ' interval in intInterval
    Dim intTime As Integer
    Dim sglTime As Single
    Dim intHour As Integer
    Dim intMinute As Integer
    Dim lngdate As Long
    ' Get the date portion of the date/time value
    lngdate = DateValue(dtmTime)
    ' Get the time portion as a number like 11.5 for 11:30.
    sglTime = TimeValue(dtmTime) * 24
    ' Get the hour and store it away. Int truncates,
    ' CInt rounds, so use Int.
    intHour = Int(sglTime)
    ' Get the number of minutes, and then round to the nearest
    ' occurrence of the interval specified.
    intMinute = CInt((sglTime - intHour) * 60)
    intMinute = CInt(intMinute / intInterval) * intInterval
    ' Build back up the original date/time value,
    ' rounded to the nearest interval.
    dhRoundTime = CDate(lngdate + ((intHour + intMinute / 60) / 24))
End Function

Open in new window

Question by:Michaelj42
    LVL 17

    Accepted Solution

    Error shows that you can not put the function outside class. Look like you have put dhRoundTime this function outside class.
    LVL 5

    Author Comment

    Oh, my End Class was at the top of the page, thanks.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now