如何检查数组中是否存在值? [英] How do you check a value exists in an array?

查看:87
本文介绍了如何检查数组中是否存在值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ASP和VBScript是否有一种聪明的方法可以轻松检查数组中是否存在值

而不通过它循环?


Steve

Using ASP with VBScript is there a clever way to easily check if a value
exists in an array without looping through it?

Steve

推荐答案

Dooza写道:
Dooza wrote:

使用ASP和VBScript有一种聪明的方法可以轻松检查如果一个数组中存在

值而没有循环通过它?
Using ASP with VBScript is there a clever way to easily check if a
value exists in an array without looping through it?






- -

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。

No

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.


Bob Barrows [MVP]写道:
Bob Barrows [MVP] wrote:

Dooza写道:
Dooza wrote:

>使用ASP和VBScript有一种聪明的方法可以轻松检查是否存在
值一个没有循环的数组?
>Using ASP with VBScript is there a clever way to easily check if a
value exists in an array without looping through it?




No



我想的多了,只是想仔细检查一下。谢谢Bob。


Steve

I thought as much, just wanted to double check. Thanks Bob.

Steve


" Dooza" < st ***** @ SPAM.dooza.tvwrote in message

新闻:OI ************** @ TK2MSFTNGP06.phx.gbl ...
"Dooza" <st*****@SPAM.dooza.tvwrote in message
news:OI**************@TK2MSFTNGP06.phx.gbl...

使用ASP和VBScript是否有一种聪明的方法可以轻松检查数组中是否存在值

而不通过它循环?
Using ASP with VBScript is there a clever way to easily check if a value
exists in an array without looping through it?



如果它是一维数组你可以尝试:


Const cVAL =" your_value"

Dim strVAL

strVAL = vbTab& cVAL& vbTab

Dim strARR

strARR = vbTab&加入(your_array,vbTab)& vbTab


如果是InStr(strARR,strVAL)0那么

WScript.Echo"''" &安培; cVAL& 找到了。

否则

WScript.Echo"''" &安培; cVAL& 找不到。

结束如果


If it''s a one dimensional array you could try:

Const cVAL = "your_value"
Dim strVAL
strVAL = vbTab & cVAL & vbTab
Dim strARR
strARR = vbTab & Join(your_array,vbTab) & vbTab

If InStr(strARR,strVAL) 0 Then
WScript.Echo "''" & cVAL & "'' found."
Else
WScript.Echo "''" & cVAL & "'' not found."
End If



这篇关于如何检查数组中是否存在值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆