Expected end of statement Error in Vb Script

I am running vb script its showing error can anyone help what is the error i cannot find what is the error it shows error

7

2 Answers

VBScript doesn't have strong types. Everything is Variant. The error message in your edit is fairly clear as to the solution:

Line:4 Char:16 - Expected end of statement.

So looking at the code...

Dim bSendEmail as boolean = true
' ^char 16

...it's telling you to end the statement there. It should be:

Dim bSendEmail
bSendEmail = True
3

CreateObject (Windows Script Host) method creates a COM object.

You need to use SET statement to assign an object reference to a variable:

''' …
Dim bSendEmail: bSendEmail = True ''' colon instead new line: it's not a good practice
''' …
If bSendEmail Then ''' ↓↓↓ SET myemail = CreateObject("CDO.Message") ''' … SET myemail = Nothing ''' ↑↑↑
End If
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like