如何执行一个小的vb脚本 [英] how to execute a small vb script

查看:193
本文介绍了如何执行一个小的vb脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行一个小的vb脚本文件,为此,我在记事本中编写了以下代码,并将该记事本文件另存为

"sampleScript.vbs"正确吗?请注意我编写的代码.发生以下错误,请帮助我

即将出现错误:缺少期望的语句

源:Vb编译错误

行:1

代码
-------

I want to execute a small vb script file, for that I wrote the following code in the notepad and saved that notepad file as

"sampleScript.vbs" is that correct? please note the code that I have written. folowing error occured please help me

Error coming : Expected statement missing

Sourece: Vb complilation error

line : 1

Code
-------

<html>
<body>
<script type="text/vbscript">
document.write("Hello World")
</script>
</body>
</html>

推荐答案

这不是VBScript,甚至都不是.它是HTML,带有一些只能在浏览器中查看的VBScript(document.write本身不是VBScript,它依赖于现有的文档对象,只有在浏览器中才是).将其另存为.htm,我相信IE会正确呈现它.任何其他浏览器都不会,只有IE可以使用VBScript.如果您想在网页中编写脚本,则可以使用javascript.
This is not VBScript, not even close. It''s HTML, with some VBScript that can only be viewed in a browser ( document.write is not VBScript per se, it relies on a document object existing, which is only true in a browser ). Save this as .htm and I believe IE will render it correctly. Any other browser will not, only IE can use VBScript. If you want to do scripting in a web page, then javascript is the way to go.


正如克里斯蒂安(Christian)所指出的,您的VBScript被嵌入 HTML页面,因此文件的正确文件扩展名是html(是的,您必须Internet Explorer,其他浏览器(例如FirefoxChrome)打开它不支持VBScript).
甚至您从中获取代码的教程 [VBScript,那么以下行就足够了:

As Christian already pointed out, your VBScript is embedded inside an HTML page, hence the correct file extension for your file is html (and, yes, you have to open it with Internet Explorer, other browsers like Firefox or Chrome don''t support VBScript).
Even the tutorial from which you grabbed the code[^] is clear about.
On the other hand, if you wan''t to create a ''stand-alone'' VBScript, then the following line is just enough:

MsgBox "Hello World"



将其另存为"hello.vbs" 并双击运行(确保在Windows计算机上运行).



save it as "hello.vbs" and double click to run (be sure to do it on a Windows machine).


这篇关于如何执行一个小的vb脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆