• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1101
  • Last Modified:

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

0
Michaelj42
Asked:
Michaelj42
1 Solution
 
sonawanekiranCommented:
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now