主题:  你们在asp中判断一个值是否位于一个数组中用什么函数

kai3000

职务:普通成员
等级:1
金币:0.0
发贴:154
注册:2002/1/8 9:41:20
#12002/10/28 5:49:43

我是这样的,判断用searchstring是否位于数组string(i)中,
instr(sting(i),searchstring)>0则表示位于数组中
但这样结果好像不对



kai3000

职务:普通成员
等级:1
金币:0.0
发贴:154
注册:2002/1/8 9:41:20
#22002/10/28 5:56:38
我想出来了
dim chk
for i = 0 to ubound(sting)
    if sting(i)=searchstring then
    chk=1
    exit for
    else
    chk=0
    end if                        
next
if chk=1 then
response.write" 存在其中"
else
response.write" 不存在"
end if



crazyf

职务:普通成员
等级:1
金币:0.0
发贴:32
注册:2002/10/8 14:21:07
#32002/10/28 16:18:22
在javascript中,有一个charAt函数,可以参考它。
------------------------------------------------------------
charAt method
Returns the character at the specified index.

语法
stringName.charAt(index)
stringName is any string or a property of an existing object.
index is any integer from 0 to stringName.length - 1, or a property of an existing object.

用法
string

描述
Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is stringName.length - 1. If the index you supply is out of range, javascript returns an empty string.

例子
The following example displays characters at different locations in the string "Brave new world".
var anyString="Brave new world"

document.write("The character at index 0 is " + anyString.charAt(0))
document.write("The character at index 1 is " + anyString.charAt(1))
document.write("The character at index 2 is " + anyString.charAt(2))
document.write("The character at index 3 is " + anyString.charAt(3))
document.write("The character at index 4 is " + anyString.charAt(4))

See also
indexOf, lastIndexOf methods