Hy我是编程vbscript的新手。我正在尝试为用户创建一个文本框,用户必须输入文件版本(格式为1,0,0,0)。用户必须在逗号中输入一个整数。但是我失败了制作一个验证脚本来做到这一点..你能帮助我吗?在此先感谢。我已创建此脚本以执行其他类型的验证,但我不知道如何对x,y,z,h格式进行验证..
Do
dtm = InputBox("Please Enter a Numeric File version using commas", _
"File version")
Select Case True
Case isNull(dtm), (not isNumeric(dtm)), dtm = "", dtm = empty, (dtm < 1 OR dtm > 9)
MsgBox "Please enter between 1 and 9"
Case else
Exit do
End Select
Loop While True
'script on test pass
答案 0 :(得分:0)
这样的事情应该完成这项工作(没有使用wscript / cscript进行测试),假设接受的数字是0到9。
Function GetVersionNumber() As String
Dim iParts, sVersion, oTmp, dtm
iParts = 0
sVersion = ""
Do
dtm = InputBox("Please Enter a Numeric File version using commas", "File version")
For Each oTmp In Split(dtm, ",")
If IsNumeric(Trim(oTmp)) Then
If Len(sVersion) > 0 Then sVersion = sVersion & ","
sVersion = sVersion & Trim(oTmp)
iParts = iParts + 1
Else
MsgBox "Please enter between 0 and 9!" & vbCrLf & "You have typed " & oTmp
iParts = 0 ' Reset to zero accepted parts
sVersion = "" ' Reset to zero length string
End If
Next
Loop Until iParts = 4 ' x,y,z,h format <- 4 parts
GetVersionNumber = sVersion
End Function