473,387 Members | 1,425 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,387 software developers and data experts.

logical and in vb ?

Sam
Hi,
I'm trying to do the following :

If I have a value of 7 then I want to test if all the values from 0 to
4 can be contained in 7:
2^0 = 1 < 7 so can be contained in 7
2^4 = 16 > 7 so can't be contained in 7

I should do something like 7&0 < 0 ? but I don't know the vb
syntax....
Can someone help?
thx

Sam

Nov 21 '05 #1
4 956
If (x And 7) = x ' x can be contained in 7

If (x And 7) <> x ' x cannot be contained in 7
"Sam" <sa**************@voila.fr> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
Hi,
I'm trying to do the following :

If I have a value of 7 then I want to test if all the values from 0 to
4 can be contained in 7:
2^0 = 1 < 7 so can be contained in 7
2^4 = 16 > 7 so can't be contained in 7

I should do something like 7&0 < 0 ? but I don't know the vb
syntax....
Can someone help?
thx

Sam

Nov 21 '05 #2
Sam
thx ;)

Nov 21 '05 #3
Sam
humm actually i'm not sure it's what i want.
it returns x all the time as long as x is < 7. But 6 (for example)
cannot be contained in 7 : 2^6 = 64 > 7

Am I wrong ?

Nov 21 '05 #4
If you are talking about using a value as a 'field' to hold 'flags' e.g.:

0
1
2
4
8
16
32
64
etc.

Then it will still work. You need to think about the bits.

111 = 7 = 4 Or 2 Or 1
110 = 6 = 4 Or 2
101 = 5 = 4 Or 1
100 = 4 = 4
011 = 3 = 2 Or 1
010 = 2 = 2
001 = 1 = 1
000 = 0 = 0

So, given:

v = 7
a = 0
b = 1
c = 2
d = 4

Then:

v = a Or b Or c Or d

If (v And a) = a Then
Debug.Print "v contains a"
Else
Debug.Print "v does not contain a"
End If

If (v And b) = b Then
Debug.Print "v contains b"
Else
Debug.Print "v does not contain b"
End If

If (v And c) = c Then
Debug.Print "v contains c"
Else
Debug.Print "v does not contain c"
End If

If (v And d) = d Then
Debug.Print "v contains d"
Else
Debug.Print "v does not contain d"
End If
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
humm actually i'm not sure it's what i want.
it returns x all the time as long as x is < 7. But 6 (for example)
cannot be contained in 7 : 2^6 = 64 > 7

Am I wrong ?

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
7
by: Charles Crume | last post by:
Hello all; I have used dBASE, and other computer languages/databases, for years. They all have a logical field type. However, the version of MySQL used by the ISP hosting my site does not...
80
by: Christopher Benson-Manica | last post by:
Of course one can get the effect with appropriate use of existing operators, but a ^^ operator would make for nice symmetry (as well as useful to me in something I'm working on). Am I the only one...
3
by: serge | last post by:
How do I determine which method I should use if I want to optimize the performance of a database. I took Northwind's database to run my example. My query is I want to retrieve the Employees'...
4
by: serge | last post by:
I am running a query in SQL 2000 SP4, Windows 2000 Server that is not being shared with any other users or any sql connections users. The db involves a lot of tables, JOINs, LEFT JOINs, UNIONS...
14
by: blueboy | last post by:
Hi, I am planning to automate a nighty restore of a DB on another server can someone point me in the right direction with the SQL script to modify the logical file names to the correct path and...
2
by: dbtwo | last post by:
Until today I always thought as long as you see a lot of logical reads as compared to physical reads, then you're good. But it looks like it isn't so. But doesn't logical read mean it's being read...
1
by: ags5406 | last post by:
Hi -- I posted this in a Fortran group but thought I'd post here as well. Any help is appreciated. I have a IVF10 DLL that is the calculation engine for a frontend application written in...
11
by: Dominic Vella | last post by:
I am using MS-Access2000. I can't seem to set the default values for Logical type fields. I start with Dim dbsTmp As Object ' I think it's DAO.Database Set dbsTmp =...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
Oralloy
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,...

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.