CBool Function

Pretvara znakovni niz za uspređivanje sa brojčanom usporedbom u Cjelobrojni izraz, ili pretvra jedinični brojčani izraz u cjelobrojni izraz

Syntax:

CBool (Expression1 {= | <> | < | > | <= | >=} Expression2) or CBool (Number)

Povratna vrijednost

Bool

Parametri:

Expression1, Expression2: Any string or numeric expressions that you want to compare. If the expressions match, the CBool function returns True, otherwise False is returned.

Number: Any numeric expression that you want to convert. If the expression equals 0, False is returned, otherwise True is returned.

The following example uses the CBool function to evaluate the value that is returned by the Instr function. The function checks if the word "and" is found in the sentence that was entered by the user.

Error codes:

5 Invalid procedure call

Primjer:

Sub ExampleCBool

Dim sText As String

    sText = InputBox("Please enter a short sentence:")

    REM Dokazuje da se riječ »i« pojavljuje u rečenici.

    REM umjesto komandne linije

    REM If Instr(Input, "and")<>0 Then...

    REM the CBool funkcija je pridružena kako slijedi:

    If CBool(Instr(sText, "and")) Then

        MsgBox "RIječ »i« se pojavljuje u rečenici koju ste upisali!"

    EndIf

End Sub