473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

VB range of values

Apologies for the simple question. I started a Visual Basic 2005 course in September and somehow I don't think we ever discussed it. Googling has been difficult because I don't know what it is called.

In SQL, you can specify a range of values. For instance:
Select *
from MyTable
where MyField in (1, 2, 3, 4)

What is the equivalent in vb. I'm using integers. I want to say
If Now.Year.ToString.Substring(3, 1) "in" and I want to show the even numbers, then do something else.

Is this simple?

Thank you in advance.
Apr 23 '07 #1
3 3256
Killer42
8,435 Expert 8TB
It's possible that the In() function is supported in VB2005. (I use the much older VB6 so I don't know).

If not, then you'll have to work around it in some way. For example, write your own function which accepts a string and an array, and returns true if the string matches any of the array entries.

The actual logic to check is quite simple - just loop through the array until you find something that matches (True) or pass the end of the array (False).

Don't forget to be on the lookout for alternative ways of solving problems, though. For instance, if you want to know whether the year is even, just use the modulo function. Not sure of the syntax in your VB version (just check the doco) but in Vb6, YourValue Mod 2 returns 0 (even) or 1 (odd).
Apr 24 '07 #2
Thank you so much. I learned 2 things in one.

So far as I can tell, I can't use "in" in VB 2005. In the future I'll use an array, and as for this problem it was easily solved with Mod. Thanks again.
Apr 24 '07 #3
Killer42
8,435 Expert 8TB
Thank you so much. I learned 2 things in one.

So far as I can tell, I can't use "in" in VB 2005. In the future I'll use an array, and as for this problem it was easily solved with Mod. Thanks again.
Glad to help. :)
Apr 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sheila King | last post by:
I have a web app that has been running just fine for several months under Python 2.2.2. We are preparing to upgrade the server to run Python 2.4.1. However, part of my web app is throwing an...
7
by: Sunny K | last post by:
Hi guys, whilst working on a project which I thought was nearly complete I have come across a problem which was some how over seen, which I am hoping one of you guys know how to resovle. ...
5
by: Patrick | last post by:
I have the following problem, (1) I have an 8-Bit microcomputer (2) It has an integer word size of 2bytes (=16 bits) (3) So int type is in the range -32768 to +32767 (4) Now I want to add...
2
by: George | last post by:
Is there a fast way to transfer an Excel range to an array? Example: Excel range is E2:E300 Dim person() as string Thanks, George
32
by: Chad | last post by:
What is the difference between range and precision in c? Also, if c doesn't support fixed point numbers, how is the addition of two integers possible? Chad
5
by: pcnerd | last post by:
I'm trying to create a program that plots randomly colored pixels on a bitmap & then displays the bitmap. When I run the program, I see the pixels being plotted down the left side of the form. When...
5
by: simchajoy2000 | last post by:
Hi, I need to calculate a range of colors given the beginning and ending colors in hex values (i.e. blue to red). I know there is a logic to hex numbers and there is probably a fairly simple...
5
by: smadala | last post by:
Hi All, I created a stored procedure with parameters in package, i used that stored procedure in crystal Reports XI..till now its working fine. Now i need to retrieve a report based on Parameter...
21
by: Bill Cunningham | last post by:
I have create these 2 files. Called main.c and atr.c. They seem to work pretty well. I just wanted to submit them to see what if any errors others that know more might find. Thanks. atr.c ...
10
by: Rafael Cunha de Almeida | last post by:
Hi, I've found several sites on google telling me that I shouldn't use rand() % range+1 and I should, instead, use something like: lowest+int(range*rand()/(RAND_MAX + 1.0))
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.