VB Student needs help with one question, Please? 
Author Message
 VB Student needs help with one question, Please?

Thank you for reading this. I am trying to teach myself VB and there is
something in the book that I don't understand.

SUB FORM_MOUSEMOVE (BUTTON AS INTEGER..............................)

IF (BUTTON AND 1) = 1 THEN                  << what the hell does this
line do ?
        CHKLEFT.VALUE = 1
ELSE
        CHKLEFT.VALUE = 0
END IF

I have taken classes in C and C++ and have never seen anything like this.

Thank you very much.



Thu, 19 Feb 1998 03:00:00 GMT  
 VB Student needs help with one question, Please?

Quote:

>IF (BUTTON AND 1) = 1 THEN                  << what the hell does this
>line do ?
>Thank you very much.

Look at the variable BUTTON as bits. Bit 1 = 1 bit 2 = 2 bit 3 = 4 . . .

The AND as used in the statement removes all bits except the first.

Thus, you could also write: If (BUTTON AND 1)>0.

Most languages would allow: if (BUTTON AND 1) but VB forces a logic TRUE
to be -1.

Good Luck,

Gary



Thu, 19 Feb 1998 03:00:00 GMT  
 VB Student needs help with one question, Please?

Quote:

>Thank you for reading this. I am trying to teach myself VB and there is
>something in the book that I don't understand.

>SUB FORM_MOUSEMOVE (BUTTON AS INTEGER..............................)

>IF (BUTTON AND 1) = 1 THEN                  << what the hell does this
>line do ?
>        CHKLEFT.VALUE = 1
>ELSE
>        CHKLEFT.VALUE = 0
>END IF

>I have taken classes in C and C++ and have never seen anything like this.

>Thank you very much.

in C/C++ this would be

if ((button & 1) == 1)

This does a bitwise AND to see if the low bit is set.

John

-----------------------------------------------
VisualWare, Inc.
Custom Visual Basic, C++, and Windows Programming
1675 East Main St, Suite 218
Kent OH 44240
(216) 297-4444

-----------------------------------------------



Thu, 19 Feb 1998 03:00:00 GMT  
 VB Student needs help with one question, Please?
1- error on install "cannot load ver.dl_ ..."
                        only on some systems, plus....
2- if someone tries to load from(with) "norton's" as their desktop,
                        crash, boom, blam, the entire system goes down in flames.
?any ideas?

ps,
please forgive vagueness and ambiguity, i am the programmer's
'conceptualizer' and stumbled on your newsgroup- just thought i'd ask :)



Fri, 20 Feb 1998 03:00:00 GMT  
 VB Student needs help with one question, Please?
1- error on install "cannot load ver.dl_ ..."
                        only on some systems, plus....
2- if someone tries to load from(with) "norton's" as their desktop,
                        crash, boom, blam, the entire system goes down in flames.
?any ideas?

ps,
please forgive vagueness and ambiguity, i am the programmer's
'conceptualizer' and stumbled on your newsgroup- just thought i'd ask :)



Fri, 20 Feb 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VB Student needs help, please.

2. VB student needs some help, please.

3. Need help with one question please

4. Need help with one question please

5. Student needing Help Please

6. Student in need of help Please

7. One Question about VB........Please help

8. !!!Please help vb student!!!

9. !!!Please help vb student!!!

10. Help: Please recommend a VB textbook for business major students

11. Student new to vb needs urgent help!

12. Students needing help in VB?

 

 
Powered by phpBB® Forum Software