VB6 Code Help


Results 1 to 6 of 6

Thread: VB6 Code Help

Threaded View

  1. #5
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Try that.

    Best regards,

    Luciano

    Code:
    Dim my_byte_value As Byte
    
    my_byte_value = 6 '(Any value from 0 to 255)
    
    If my_byte_value And 1 Then
        Check1.Value = 1
    Else
        Check1.Value = 0
    End If
    
    If my_byte_value And 2 Then
        Check2.Value = 1
    Else
        Check2.Value = 0
    End If
    
    If my_byte_value And 4 Then
        Check3.Value = 1
    Else
        Check3.Value = 0
    End If
    
    If my_byte_value And 8 Then
        Check4.Value = 1
    Else
        Check4.Value = 0
    End If
    
    If my_byte_value And 16 Then
        Check5.Value = 1
    Else
        Check5.Value = 0
    End If
    
    If my_byte_value And 32 Then
        Check6.Value = 1
    Else
        Check6.Value = 0
    End If
    
    If my_byte_value And 64 Then
        Check7.Value = 1
    Else
        Check7.Value = 0
    End If
    
    If my_byte_value And 128 Then
        Check8.Value = 1
    Else
        Check8.Value = 0
    End If
    Below is the reverse action using the OR operation:
    (Same result as my first post).
    Code:
    Dim my_byte_value As Byte
    
    my_byte_value = 0
    
    If Check1.Value = 1 Then my_byte_value = my_byte_value Or 1
    If Check2.Value = 1 Then my_byte_value = my_byte_value Or 2
    If Check3.Value = 1 Then my_byte_value = my_byte_value Or 4
    If Check4.Value = 1 Then my_byte_value = my_byte_value Or 8
    If Check5.Value = 1 Then my_byte_value = my_byte_value Or 16
    If Check6.Value = 1 Then my_byte_value = my_byte_value Or 32
    If Check7.Value = 1 Then my_byte_value = my_byte_value Or 64
    If Check8.Value = 1 Then my_byte_value = my_byte_value Or 128
    Last edited by Luciano; - 14th July 2006 at 13:03.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. VB6 Code Help
    By charudatt in forum Serial
    Replies: 5
    Last Post: - 20th December 2005, 19:39

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts