Link to home
Start Free TrialLog in
Avatar of Jeanniem
Jeanniem

asked on

SSRS custom code [BC30037] Character not valid

I am using the following custom code in SQL Services Reporting Services (2005).
Function fmtreg(ByVal regtime As string) As String
dim newregtime As String
dim length As Integer
length = len(trim(regtime))
Select Case length
      Case length < 4
            return "error"
      Case = 4
            newregtime =   "0" & left(regtime,1) & ":" & "0" & mid(regtime,2,1)
            return newregtime
      Case =  5
            newregtime =  "0" & left(regtime,1) & ":" & mid(regtime,2,2)
            return newregtime
      Case = 6
            newregtime =  left(regtime,2) & ":"  & mid(regtime,3,2)
            return newregtime
      Case length > 6
            return "error"
End Select            
End Function
Function GetDays(ByVal CDateofReg As Date, CdateNewDocSees As Date, DocSees As Date)As Integer
Dim minsinhour as Integer
Dim RegToDocSees2 As Integer
Dim Sameday As Boolean
If  Day(CDateofReg) = Day(CdateNewDocSees) Then
      Sameday = true
Else
      Sameday = false
End If
minsinhour = 60
If  IsNothing(DocSees)  Then
      RegToDocSees2 = 0
      Return RegToDocSees2
End If
If Sameday  =  true Then
 RegToDocSees2 = DateDiff("n",CdateNewDocSees,CDateOfReg)
Return RegToDocSees2                                          
Else
      RegToDocSees2 = ((minsinhour  Minute(CDateofReg)) + Minute(CdateNewDocSees))
      Return RegToDocSees2
End If
End Function

When I execute, I get the following error message:
There is an error in line 38 of custom code [BC30037] Character not valid

Can anyone help me with this?
Avatar of ptakja
ptakja
Flag of United States of America image

This is a shot in the dark, since I don't know what code is on line 38, but this code is close given your listing:

 RegToDocSees2 = ((minsinhour  Minute(CDateofReg)) + Minute(CdateNewDocSees))

Looks like to !! (exclamation points) between "minsinhour" and Minute(....

I think that is C# syntax, which isn't valid in VB.
Avatar of Jeanniem
Jeanniem

ASKER

I don't know why that line of code shows up like it does above - in the actual report there is a minus sign (-) between minsinhour and Minute(...).  I retyped the line just to be sure it didn't contain any weird errors but still get the same error message.
Avatar of RobSampson
Hi, what editor are you using?  Is it possible that the editor you are using is autoformatting the minus sign to a longer hyphen or something?

Rob.
I'm using Visual Studio 2005 - do you think that would autoformat?
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial