我在打印功能打印时遇到了运行时错误
print "knvc"
答案 0 :(得分:2)
在c / wscript.exe脚本主机下运行本机/普通VBScript中没有print
Sub(其他主机 - 例如QTP - 可能提供一个)。请改用WScript.Echo
。
更新评论:
演示VBScript的控制台输出(在'dos box'中使用cscript;从编辑器启动脚本或从explorer双击可能通过wscript.exe运行它,然后你会得到一个令人讨厌的惊喜):
26337387.vbs
Option Explicit
Dim sInp : sInp = "Hyderabad"
Dim i
For i = 1 to Len(sInp)
' print mid(d,i,1) ' no native print in VBScript.
WScript.Echo Mid(sInp, i, 1) ' each character on its own line
Next
For i = 1 to Len(sInp)
WScript.StdOut.Write Mid(sInp, i, 1) ' each character on the same line
Next
输出:
cscript 26337387.vbs
H
y
d
e
r
a
b
a
d
Hyderabad