VBScript if,do,while test not right right right

时间:2016-10-08 00:54:20

标签: vbscript

'Assign name, age, phone number, address, and birthday variables

WScript.Echo ("Please Enter Employee's name")
name = WScript.StdIN.ReadLine
If name = Null then
Wscript.Echo ("You must Enter Employee's Name")
Do While name = nothing
    WScript.Echo ("Please Enter Employee's name")
    name = WScript.StdIN.ReadLine
Loop
End If

这是我的vbscript代码,试图将name变量测试为null,如果空循环不为空。

1 个答案:

答案 0 :(得分:0)

我尝试了下面的代码并将其作为cscript test-input.vbs运行,这似乎可以做你想要的。

测试input.vbs

'Assign name, age, phone number, address, and birthday variables

WScript.Echo ("Please Enter Employee's name")
name = WScript.StdIN.ReadLine
Do While name = ""
    WScript.Echo ("Name is required - Please Enter Employee's name")
    name = WScript.StdIN.ReadLine
Loop