Link to home
Start Free TrialLog in
Avatar of jackjohnson44
jackjohnson44

asked on

class bave a blank property

I have a class called status which is pretty much just a status boolean, and a message.

So I can return, false, and "Failed for this reason"

Is there a way to return a value when you reference the object, without a property?


        Dim saveTestResults As Status
        MsgBox(saveTestResults.status) 'would pop up true or false

        MsgBox(saveTestResults) 'I would like this to also return true or false
        if (saveTestResults) then 'this is what I really want to do
        end if

Public Class Status

    Private myStatus As Boolean = False
    Private myMessage As String = ""

    Public Property status() As Boolean
        Get
            status = myStatus
        End Get
        Set(ByVal value As Boolean)
            myStatus = value
        End Set
    End Property

    Public Property message() As String
        Get
            message = myMessage
        End Get
        Set(ByVal value As String)
            myMessage = value
        End Set
    End Property

    Public Sub setStatus(ByVal message$, ByVal status As Boolean)

        myStatus = status
        myMessage = message

    End Sub

End Class
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland 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