Función CBool

Converte unha comparación numérica ou de cadeas nunha expresión booleana, ou converte unha única expresión numérica nunha expresión booleana.

Sintaxe:


CBool (Expresión1 {= | <> | < | > | <= | >=} Expresión2) ou CBool (Número)

Valor de retorno:

Bool

Parámetros:

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.

Códigos de erro

5 Chamada de procedemento incorrecta

Exemplo:


Sub ExampleCBool
Dim sText As String
    sTexto = InputBox("Escriba unha frase curta:")
    REM Verificar se a palabra »e« aparece na frase.
    REM En vez da liña de ordes
    REM If Instr(Input, "e")<>0 Then...
    REM a función CBool aplícase desta forma:
    If CBool(Instr(sTexto, "e")) Then
        MsgBox "A palabra »e« aparece na frase que introduciu!"
    EndIf
End Sub

Precisamos da súa axuda!