0

Why am I getting a type mismatch error on line 4 when I execute the below code?

Function delete()
    delete= True
End function
delete() = False
if delete() = False then
    MsgBox "Yes"
else
    MsgBox "No"
end if  

1 Answer 1

3

You can't assign a value to a function this way delete() = False

You need to remove this line delete() = False. I don't see any use with line 4.

Sign up to request clarification or add additional context in comments.

5 Comments

If i put delete = False then i am getting Illegal assignment error and why it is not giving type mismatch with if statement?
@user3313770: You need to remove line 4
@user3313770 You can't assign a value to a function. At all. Functions are not properties.
@AnsgarWiechers Though you can assign a value to the function name, of course, from within the function. That is, the function's return value.
@Bond Yes. That's how functions return values in VBScript. And it only works for each function name inside its own body.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.