Vbscript 代码中有什么错误吗
我有如下代码。要拆分数字,我使用以下代码。现在我需要拆分MyArray中的值存储Vbscript 代码中有什么错误吗,vbscript,Vbscript,我有如下代码。要拆分数字,我使用以下代码。现在我需要拆分MyArray中的值存储 <html> <body onload = "VerifyTimeSelectionNew();"> <script language="VBScript"> Const LEVEL_DATE_RANGE1 = 110 Function VerifyTimeSelectionNew() 'Dim cboTime 'cboTime
<html>
<body onload = "VerifyTimeSelectionNew();">
<script language="VBScript">
Const LEVEL_DATE_RANGE1 = 110
Function VerifyTimeSelectionNew()
'Dim cboTime
'cboTime = document.getElementsByName("TimeDropdown:cboTime")
'If CInt(cboTime.options(cboTime.selectedIndex).value) = LEVEL_DATE_RANGE1 Then
Dim hdnTime
Dim MyArray, i, newValue,value,newArray
hdnTime="0:0:0:0:0:2:201201:201311:False:False:True:False"
MyArray = Split(hdnTime, ":")
For i = 0 to 3
MsgBox (MyArray(i))
Next
value = MyArray(7)
newArray = split(value ,"")
// newValue = value.substring(0,4)
MsgBox(newArray(0))
End Function
</script>
</body>
</html>
常数级别\u日期\u范围1=110
函数VerifyTimeSelectionNew()
“昏暗的时间
'cboTime=document.getElementsByName(“时间下拉列表:cboTime”)
'如果CInt(cboTime.options(cboTime.selectedIndex.value)=级别\日期\范围1,则
暗时间
Dim MyArray,i,newValue,value,newArray
hdnTime=“0:0:0:0:2:201201:201311:假:假:真:假”
MyArray=Split(hdnTime,“:”)
对于i=0到3
MsgBox(MyArray(i))
下一个
value=MyArray(7)
newArray=split(值为“”)
//newValue=值。子字符串(0,4)
MsgBox(新数组(0))
端函数
当我执行此命令时,我得到了201311。我无法拆分201311。你能告诉我是什么吗?你的代码片段有几个问题
Substring()
。改为使用该函数Dim value As String = "JohnRich"
Dim subString As String = value.Substring(0,4)
为此:
Dim value : value = "JohnRich"
Dim subString : subString = Left(value, 4)
或者这个:
Dim value, subString
value = "JohnRich"
subString = Left(value, 4)
我不认为你可以在VBScript中声明和分配变量作为一个单独的语句(不像,比如说,VB.Net)@Damien_不信者:谢谢!!我已经编辑了剧本。你能帮我吗?请不要移动目标。您的编辑是一个完全不同的问题,所以您应该将其作为新问题发布。@AnsgarWiechers:非常感谢:):)。很抱歉编辑了同一个问题:(