Link to home
Create AccountLog in
Avatar of NigelRocks
NigelRocks

asked on

Compile Error in Visual Basic 6.0

I'm attempting to read 2 values out of a SQL Server database and to store those data in public form values in Visual Basic 6.0.  The variables are defined as follows:


Public mbCooperativeAgreement As Boolean
Public msFundingPurposeCategory As String


I attempt to assign values to them during form load like this:


mbCooperativeAgreement = bGetBoolean(rs, "Is_Cooperative_Agreement")
msFundingPurposeCategory = sGetDBString(rs, "Funding_Purpose_Category")


When I do, I get the following error:
Compile error: Function call on left side of assignment must return variable or object


It seems to think my variables are funcitons.  The methods that they use to assigned values to those variables are shown below:


Function bGetBoolean(rs As rdoResultset, ByVal field_name As String) As Boolean
' null returns 0

    Const nTRUE = 1

    Dim save_mousepointer As Integer
    Dim errorMsg As String
   
    On Error GoTo errorInt
   
    Dim i As Integer
   
    If Not IsNull(rs(field_name)) Then
      i = Val(CInt(rs(field_name)))
    Else
      i = 0 'null
    End If
   
    If i = nTRUE Then
        bGetBoolean = True
    Else
        bGetBoolean = False
    End If
       
   
    Exit Function
errorInt:
        save_mousepointer = Screen.MousePointer
        Screen.MousePointer = 0
        errorMsg = "Encountered unexpected error: " & "Code: " & err & " " & Error$
        MsgBox errorMsg, , "al.bas: getBoolean field_name=" & field_name
        Screen.MousePointer = save_mousepointer
        getDbIntValue = 0
        Exit Function
End Function



Function sGetDBString(rs As rdoResultset, ByVal field_name As String) As String

    Dim save_mousepointer As Integer
    Dim errorMsg As String
   
    On Error GoTo errorInt
   
        If Not IsNull(rs(field_name)) Then
          sGetDBString = Val(CInt(rs(field_name)))
        Else
          sGetDBString = ""
        End If
       
    Exit Function
errorInt:
        save_mousepointer = Screen.MousePointer
        Screen.MousePointer = 0
        errorMsg = "Encountered unexpected error: " & "Code: " & err & " " & Error$
        MsgBox errorMsg, , "al.bas: getBoolean field_name=" & field_name
        Screen.MousePointer = save_mousepointer
        getDbIntValue = 0
        Exit Function
End Function

Does anyone know what might be going on here?

Avatar of NigelRocks
NigelRocks

ASKER

Correction:

The actual error message says "left-HAND" side instead of just "left side".
AnNOTHer correction;

The error message says "variant or object" instead of "variable or object".

It's been a long day.
ASKER CERTIFIED SOLUTION
Avatar of Dana Seaman
Dana Seaman
Flag of Brazil image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.