作者:nj擁我自己的天空 | 来源:互联网 | 2023-02-12 17:12
1> Lankymart..:
你犯了几个错误,这就是为什么你没有得到预期的结果.
在检查Array的边界时,您需要指定Array变量,在这种情况下,生成的变量Split()
是CitizenshipCountry
.
通过在括号((...)
)中指定元素序号位置而不是方括号([...]
)来访问数组元素.
试试这个:
<%
Dim SelectedCountries, CitizenshipCountry, Count
SelectedCountries = "IN, CH, US"
CitizenshipCountry = Split(SelectedCountries,", ")
'Get the count of the array not the string.
Count = UBound(CitizenshipCountry)
'Use (..) when referencing array elements.
Call Response.Write(CitizenshipCountry(0))
Call Response.End()
%>
我喜欢做的是IsArray
在调用之前检查变量是否包含有效数组UBound()
以避免这些类型的错误.
<%
Dim SelectedCountries, CitizenshipCountry, Count
SelectedCountries = "IN, CH, US"
CitizenshipCountry = Split(SelectedCountries,", ")
'Get the count of the array not the string.
If IsArray(CitizenshipCountry) Then
Count = UBound(CitizenshipCountry)
'Use (..) when referencing array elements.
Call Response.Write(CitizenshipCountry(0))
Else
Call Response.Write("Not an Array")
End If
Call Response.End()
%>
非常感谢,这就像一个魅力,我是classis asp的新手,从来没有使用过,只需要在旧应用上做一些修复,谢谢你的帮助:)(Y).