简体   繁体   中英

Type Mismatch In VBScript

I have a function with 2 parameter inputs, the function does some logic and then assigns a True or False value to it's output (the function name). I can see that the function logic is working correctly through MsgBox outputs, however it seems to not be assigning the value to the variable correctly.

Here's a snippet of what's happening:

From earlier in my code:

If FunctionName(x,y) = 1 Then
    MsgBox = "It's happening!"

Which is not returning 1 for some reason. The function itself looks like this:

MsgBox "Found a match!"

delete = 1

MsgBox "Delete value is: " + CInt(delete)

FunctionName = delete

When I run this, I get the "Found a match!" message and then immediately get a "Type mismatch error" on the 2nd MsgBox line and it appears that the delete value is just empty. I tried adding the CInt conversion as I read that may be the problem, but it didn't make a difference.

Any thoughts on this?

Edit: Woo, changing the + to & worked for spitting out the MsgBox with delete = 1 ! I am still having some issues getting that 1 value to trigger my original If statement that calls the function, though.

To concatenate strings, use the & .

Like this:

MsgBox "Found a match!"
delete = 1
MsgBox "Delete value is: " & delete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM