Using ASP with VBScript is there a clever way to easily check if a value
exists in an array without looping through it?
Steve 10 41165
Dooza wrote:
Using ASP with VBScript is there a clever way to easily check if a
value exists in an array without looping through it?
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] wrote:
Dooza wrote:
>Using ASP with VBScript is there a clever way to easily check if a value exists in an array without looping through it?
No
I thought as much, just wanted to double check. Thanks Bob.
Steve
"Dooza" <st*****@SPAM.d ooza.tvwrote in message
news:OI******** ******@TK2MSFTN GP06.phx.gbl...
Using ASP with VBScript is there a clever way to easily check if a value
exists in an array without looping through it?
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,st rVAL) 0 Then
WScript.Echo "'" & cVAL & "' found."
Else
WScript.Echo "'" & cVAL & "' not found."
End If
"McKirahan" <Ne**@McKirahan .comwrote in message
news:Wo******** *************** *******@comcast .com...
"Dooza" <st*****@SPAM.d ooza.tvwrote in message
news:OI******** ******@TK2MSFTN GP06.phx.gbl...
Using ASP with VBScript is there a clever way to easily check if a value
exists in an array without looping through it?
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,st rVAL) 0 Then
WScript.Echo "'" & cVAL & "' found."
Else
WScript.Echo "'" & cVAL & "' not found."
End If
An interesting solution. Arguably that is two loops one peformed by the
join and the second by the instr but since both 'loops' in compiled code
that would well be faster than an basic For loop in VBScript but I doubt it,
I'll have to test that.
--
Anthony Jones - MVP ASP/ASP.NET
Anthony Jones wrote:
"McKirahan" <Ne**@McKirahan .comwrote in message
news:Wo******** *************** *******@comcast .com...
>"Dooza" <st*****@SPAM.d ooza.tvwrote in message news:OI******* *******@TK2MSFT NGP06.phx.gbl.. .
>>Using ASP with VBScript is there a clever way to easily check if a value exists in an array without looping through it?
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,st rVAL) 0 Then WScript.Echo "'" & cVAL & "' found." Else WScript.Echo "'" & cVAL & "' not found." End If
An interesting solution. Arguably that is two loops one peformed by
the join and the second by the instr but since both 'loops' in
compiled code that would well be faster than an basic For loop in
VBScript but I doubt it, I'll have to test that.
I would have thought the impact of string conversion and concatentation
would be intolerable. To the OP: looping through an array is fast
(especially if the contents are sorted so unsuccessful searches can be
aborted early), so why look for an alternative?
--
Anthony Jones - MVP ASP/ASP.NET
--
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] wrote:
>>Another would be to not use an array but a Dictionary.
I think I am restricted to whatever ADSI gives me, but I could be wrong. See my code somewhere above.
? There is nothing restricting you to using an array vs. a Dictionary.
A dictionary allows me to use name/value pairs, is that right? I am only
needing the name of the group that the user is a member of, what would I
use as the pair?
Steve
Dooza wrote:
Bob Barrows [MVP] wrote:
>>>Another would be to not use an array but a Dictionary.
I think I am restricted to whatever ADSI gives me, but I could be wrong. See my code somewhere above.
? There is nothing restricting you to using an array vs. a Dictionary.
A dictionary allows me to use name/value pairs, is that right? I am
only needing the name of the group that the user is a member of, what
would I use as the pair?
You could store an array of the group members, i.e
key: groupname
value: array of group members
I'm not saying this the correct way to do this: simply offering an
alternative.
--
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]" <re******@NOyah oo.SPAMcomwrote in message
news:uK******** ******@TK2MSFTN GP02.phx.gbl...
Anthony Jones wrote:
"McKirahan" <Ne**@McKirahan .comwrote in message
news:Wo******** *************** *******@comcast .com...
"Dooza" <st*****@SPAM.d ooza.tvwrote in message
news:OI******** ******@TK2MSFTN GP06.phx.gbl... Using ASP with VBScript is there a clever way to easily check if a value exists in an array without looping through it?
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,st rVAL) 0 Then
WScript.Echo "'" & cVAL & "' found."
Else
WScript.Echo "'" & cVAL & "' not found."
End If
An interesting solution. Arguably that is two loops one peformed by
the join and the second by the instr but since both 'loops' in
compiled code that would well be faster than an basic For loop in
VBScript but I doubt it, I'll have to test that.
I would have thought the impact of string conversion and concatentation
would be intolerable.
Join is somewhat more effecient at contentation but its a good point it
probably would be a killer.
--
Anthony Jones - MVP ASP/ASP.NET
"Dooza" <st*****@SPAM.d ooza.tvwrote in message
news:e6******** ******@TK2MSFTN GP06.phx.gbl...
McKirahan wrote:
"Dooza" <st*****@SPAM.d ooza.tvwrote in message
news:OI******** ******@TK2MSFTN GP06.phx.gbl...
Using ASP with VBScript is there a clever way to easily check if a
value
exists in an array without looping through it?
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,st rVAL) 0 Then
WScript.Echo "'" & cVAL & "' found."
Else
WScript.Echo "'" & cVAL & "' not found."
End If
I am using ADSI on our intranet, and only want to show certain users
certain menu items.
What I have done is this:
<%
Dim groupIT
Dim groupSALES
Dim groupACCOUNTS
Dim groupADMIN
For Each objGroup In ObjUser.Groups
If objGroup.Name = "IT" Then groupIT = 1
If objGroup.Name = "UK Sales" Then groupSALES = 1
If objGroup.Name = "Accounts" Then groupACCOUNTS = 1
If objGroup.Name = "Domain Admins" Then groupADMIN = 1
Next
<snip>
Its doubtful that the set of groups for user would be large. You're also
testing for multple values in a single loop which makes good use of the
loop. I would say your done here move on.
--
Anthony Jones - MVP ASP/ASP.NET This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dixie |
last post by:
I am trying to write some VBA that can check if a certain value exists in a
field in a table. The field is a text field. The table is not a part of the
query that forms the recordsource of the form on which I am trying to do
this. I wish to act on the presence (or absence) of this value. What I am
doing is trying to have a generic password form such that when you click a
button to open the next form, the code checks if there is a letter...
|
by: James |
last post by:
vb.net 2003
i wrote a windows service that does threading. My codes are
a) the service thread will read a list of machine from a text file
(machines.txt).
b) it then logon using the below
Dim returnValue As Boolean = LogonUser(m_ntid, m_domain, m_pwd,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, tokenHandle)
|
by: Ros |
last post by:
Peeps,
I need help with trying to find a value in array of arrays.
Public Module myModule
Private Site_Access() As Array
Property Set_SA()
Get
Return Site_Access
End Get
|
by: codefire |
last post by:
Hi,
I have some simple code - which works...kind of..here's the code:
import os
def print_tree(start_dir):
for f in os.listdir(start_dir):
fp = os.path.join(start_dir, f)
|
by: =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?= |
last post by:
Hello.
I am reading a value from a table and trying to determine if that value
exists in a list of values associated with a dropdownlist. If so, I select
the value, otherwise, I don't. I haven't been able to figure this operation
out so far.
Code:
if (reader != System.DBNull.Value)
| |
by: causesdrowsiness |
last post by:
Hi everyone.
Sorry if this is the wrong group for this question, but since it
is .NET and VB, I thought someone may be able to help me here or point
me to the right group for this.
I am working on an application which needs to check if a certain VALUE
exists in a registry subkey. Is there an easy way to do this? So far,
my googles have come up empty on this, though they DO have a plethora
of information on checking if a KEY exists.
|
by: priyanka1915 |
last post by:
helloo,
I have to retrive the data from database and then check that value
my column in database is
CATEGORY
-------------------------------
COMMODITY
COMMODITY
COMMODITY
|
by: Manikgisl |
last post by:
HI.
How to check File exists in Web Share C#
try
{
WebRequest request = HttpWebRequest.Create("http://www.microsoft.com/NonExistantFile.aspx");
request.Method = "HEAD"; // Just get the document headers, not the data.
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
// This may throw a WebException:
|
by: qwedster |
last post by:
Folk!
How to programattically check if null value exists in database table (using stored procedure)?
I know it's possble in the Query Analyzer (see last SQL query batch statements)?
But how can I pass null value as parameter to the database stored procedure programattically using C#?
Although I can check for empty column (the following code passes string.Empty as parameter but how to pass null value?), I cannot check for null value...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |