Error Running VBScript from NotePad

风格不统一 提交于 2020-07-19 08:58:12

问题


I am new to vbscript and running procedures. I found some code that I'm trying to test so that I can get a feel for how vbscript works, and I am not sure why I am receiving an error message. I have created the below code in NotePad and then saved the file as a .vbs file on my desktop. Here is the code:

i=10

If i=10 Then

msgbox("This is my first script, Click OK to close")

Else

msgbox(“Hello world”)

End if

I thought that I would be able to open the file and get the message. Instead I am receiving the following error message:

Windows Script Host

Script: (my file location on my desktop) Line: 9 Char: 8 Error:

Invalid character Code: 800A0408 Source: Microsoft VBScript compilation error


回答1:


Replace

msgbox(“Hello world”)

with

msgbox("Hello world")




回答2:


It looks like line 9 character 8 is a “ and not a " character. That is probably the issue. You would also need to replace the ” character after world with a " character.



来源:https://stackoverflow.com/questions/46434237/error-running-vbscript-from-notepad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!