error BC30001: Statement is not valid in a namespace

Gurus,

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:
http://msdn.microsoft.com/en-us/library/aa227556%28v=vs.60%29.aspx

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

LVL 5
Michaelj42Asked:
Who is Participating?
 
Kiran SonawaneConnect With a Mentor Project LeadCommented:
Error shows that you can not put the function outside class. Look like you have put dhRoundTime this function outside class.
0
 
Michaelj42Author Commented:
Oh, my End Class was at the top of the page, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.