I'd like to avoid coding a long set of IF... OR IF...statements.
I can do a Select Case, but that would only let me case out on
a single value.
What I'm looking for is something like
If thisVal OR thatVal AMONG("X", "Y", "Z")....
The main thing is getting the allowed values in one place where the next guy can
see/update them easily.
Somehow Enum comes to mind...
--
PeteCresswell 11 4237
RE/ I'd like to avoid coding a long set of IF... OR IF...statements.
The actual statements are:
------------------------------------------------
If !Val_MSD = "COP" _
Or !Val_MSD = "GO" _
Or !Val_MSD = "ETM" _
Or !Val_MSD = "INS" _
Or !Val_MSD = "MISC" _
Or !Val_MSD = "PRE-RE" _
Or !Val_MSD = "REV" _
Or !Val_MLD = "COP" _
Or !Val_MLD = "GO" _
Or !Val_MLD = "ETM" _
Or !Val_MLD = "INS" _
Or !Val_MLD = "MISC" _
Or !Val_MLD = "PRE-RE" _
Or !Val_MLD = "REV" Then
theReason = "When FIMA2 value='BOND' and Fimma-1 value among
('COP', 'GO', 'ETM', 'INS', 'MISC', 'PRE-RE', 'REV') difference is OK."
------------------------------------------------
--
PeteCresswell
(Pete Cresswell) wrote: I'd like to avoid coding a long set of IF... OR IF...statements.
I can do a Select Case, but that would only let me case out on a single value.
What I'm looking for is something like
If thisVal OR thatVal AMONG("X", "Y", "Z")....
Case "X", "Y", "Z" is a valid statement in a Select Case block.
"(Pete Cresswell)" wrote: I'd like to avoid coding a long set of IF... OR IF...statements.
I can do a Select Case, but that would only let me case out on a single value.
What I'm looking for is something like
If thisVal OR thatVal AMONG("X", "Y", "Z")....
The main thing is getting the allowed values in one place where the next guy can see/update them easily.
Somehow Enum comes to mind... -- PeteCresswell
Sometimes I may do something like this
Dim s as string
Dim sSearch as string
s = "*Mike*Sam*Joe*"
sSearch = "Joe"
If instr(s,"*" & strSearch & "*") > 0 then...
I'm using 97 tho.
Nice one, will keep that in memory! Thanks.
Salad wrote: s = "*Mike*Sam*Joe*" If instr(s,"*" & strSearch & "*") > 0 then... I'm using 97 tho.
So? Does InStr get deprecated somewhere?
--
Bas Cost Budde
"(Pete Cresswell)" <x@y.z> wrote in
news:ik********************************@4ax.com: RE/I'd like to avoid coding a long set of IF... OR IF...statements.
The actual statements are: ------------------------------------------------ If !Val_MSD = "COP" _ Or !Val_MSD = "GO" _ Or !Val_MSD = "ETM" _ Or !Val_MSD = "INS" _ Or !Val_MSD = "MISC" _ Or !Val_MSD = "PRE-RE" _ Or !Val_MSD = "REV" _ Or !Val_MLD = "COP" _
Or !Val_MLD = "GO" _ Or !Val_MLD = "ETM" _ Or !Val_MLD = "INS" _ Or !Val_MLD = "MISC" _ Or !Val_MLD = "PRE-RE" _ Or !Val_MLD = "REV" Then theReason = "When FIMA2 value='BOND' and Fimma-1 value among ('COP', 'GO', 'ETM', 'INS', 'MISC', 'PRE-RE', 'REV') difference is OK." ------------------------------------------------
How about
if isInlist(!val_msd) or isinlist(!val_mld) then ...
Public Function isInList(stFind As String) As Boolean
Dim stItems As String
stItems = "cop,go,etm,ins,misc,pre-re,rev"
isInList = InStr(1, stItems, stFind) > 0
End Function
Bob Q
Bob Quintal wrote: How about if isInlist(!val_msd) or isinlist(!val_mld) then ...
Public Function isInList(stFind As String) As Boolean Dim stItems As String stItems = "cop,go,etm,ins,misc,pre-re,rev" isInList = InStr(1, stItems, stFind) > 0 End Function
Bob Q
A nice function, short and sweet.
You might need to adjust that for numbers tho. Ex: you pass the number
1 and the string contains an 11. And you need to consider strings too..
Ex: you are searching for Bob and the string contains "Bobbie". That's
why I put a delimiter around each item in the string and the search
for...I use an * but any character would work.
RE/ if isInlist(!val_msd) or isinlist(!val_mld) then ...
Public Function isInList(stFind As String) As Boolean Dim stItems As String stItems = "cop,go,etm,ins,misc,pre-re,rev" isInList = InStr(1, stItems, stFind) > 0 End Function
That's the kind of functionality I was looking for.
Thanks!
--
PeteCresswell
On Sun, 01 Feb 2004 01:21:15 GMT in comp.databases.ms-access, "(Pete
Cresswell)" <x@y.z> wrote: I'd like to avoid coding a long set of IF... OR IF...statements.
I can do a Select Case, but that would only let me case out on a single value.
What I'm looking for is something like
If thisVal OR thatVal AMONG("X", "Y", "Z")....
The main thing is getting the allowed values in one place where the next guy can see/update them easily.
Somehow Enum comes to mind...
An alternative to Bob's excellent function is the use of separate
parameters in an array...
Function Among(pvarWhat, ParamArray pvarAr()) As Boolean
Dim i As Long
For i = LBound(pvarAr) To UBound(pvarAr)
If pvarWhat = pvarAr(i) Then
Among = True
Exit For
End If
Next
End Function
--
A)bort, R)etry, I)nfluence with large hammer.
RE/ Function Among(pvarWhat, ParamArray pvarAr()) As Boolean Dim i As Long For i = LBound(pvarAr) To UBound(pvarAr) If pvarWhat = pvarAr(i) Then Among = True Exit For End If Next End Function
I like that even better - just because it reads better when coded in the calling
routine.
--
PeteCresswell
"(Pete Cresswell)" <x@y.z> wrote in message
news:83********************************@4ax.com... RE/Function Among(pvarWhat, ParamArray pvarAr()) As Boolean Dim i As Long For i = LBound(pvarAr) To UBound(pvarAr) If pvarWhat = pvarAr(i) Then Among = True Exit For End If Next End Function I like that even better - just because it reads better when coded in the
calling routine.
Why not use a table for your static values and a query to see if the
variable
exists in the table? Wasn't management of the static values one of the
reasons
for the question?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Have any of you thought of using the Eval() function? (debug window):
? eval("2 in (2, 3)")
- -1
Eval() returns true if 2 is in the list (2, 3); false if 2 is not in
the list.
Rgds,
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQCB6oYechKqOuFEgEQK6ZQCgxM99LSJTkZ2J8yK9PytZWR qmO2EAniKi
ZqzZunNsiRdP42ghLJ2t8tot
=AqrY
-----END PGP SIGNATURE-----
(Pete Cresswell) wrote: RE/
Function Among(pvarWhat, ParamArray pvarAr()) As Boolean Dim i As Long For i = LBound(pvarAr) To UBound(pvarAr) If pvarWhat = pvarAr(i) Then Among = True Exit For End If Next End Function
I like that even better - just because it reads better when coded in the calling routine. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Robert Ferrell |
last post by:
I'm trying to "extend" Python by writing a bit of C code. I followed
the example in the Python documentation, and almost everything works
fine. I can build a DLL, fire up an interactive Python...
|
by: Rob Evans |
last post by:
Is there a way of stopping " - Microsoft Internet Explorer" being added to
the browser window title ?
eg, I want it to say:
My Website Name
and not
My Website Name - Microsoft Internet...
|
by: Robbie Hatley |
last post by:
I'm getting a bizarre error with this code:
...
case WM_COMMAND:
{
switch (LOWORD(wParam)) // switch (control ID)
{
...
case IDC_RAIN_ENABLE_SIMPLE:
{
|
by: Andre |
last post by:
Hi,
Does anyone know whether the ECMA, or an other standard document,
specifies a maximum for the value that can be pass to the setTimeOut()
function in Javascript?
Andre
|
by: monomaniac21 |
last post by:
Hi all ive added a form to a script using php and the form is to hold
sizes of a product which means the client needs to be able to use " to
denote inches. However when this is entered and the form...
|
by: Eric |
last post by:
Hello,
I have some server side includes on a Classic asp page that look
something like:
<!-- #include virtual="/includes/file1.asp"-->
<!-- #include virtual="/includes/file2.asp" -->
<!--...
|
by: Ole Mercano |
last post by:
When I create in Designer a new button on my Form it is automatically
named e.g. "button1".
When I doubleclick on it I am directed to the Form.cs where the following
procedure is automatcially...
|
by: Chris Thomasson |
last post by:
I was wondering if the 'SLINK_*' and 'SLIST_*' macros, which
implement a simple singly-linked list, will produce _any_ possible
undefined behavior:
____________________________
#include...
|
by: Lloyd Bonafide |
last post by:
I followed a link to James Kanze's web site in another thread and was
surprised to read this comment by a link to a GC:
"I can't imagine writing C++ without it"
How many of you c.l.c++'ers use...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |