VB6 Code Help


Closed Thread
Results 1 to 6 of 6

Thread: VB6 Code Help

  1. #1
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161

    Default VB6 Code Help

    Hello friends,

    I am writing a VB6 Code to serially program a RTC Module via PIC for Alarm Time.

    I am interested in knowing how to build a byte variable from 8 Check Boxes to be transfered to the Chip. These Check Boxes are to be labelled Days of the week the alarm needs to be on.

    regards.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Make things simple. Use some Text box and a Command button. Once you click on the Command button it send the whole string of the Texts boxs.

    In the PIC side, you use the right modifier (HEX, DEC, STR).

    If you need some VB EBook, drop me your e-mail address in my PM.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Try that:

    Code:
    Dim my_byte_value as byte
    
    my_byte_value = 0
    
    If Check1.Value = 1 Then  my_byte_value = my_byte_value + 1
    If Check2.Value = 1 Then  my_byte_value = my_byte_value + 2
    If Check3.Value = 1 Then  my_byte_value = my_byte_value + 4
    If Check4.Value = 1 Then  my_byte_value = my_byte_value + 8
    If Check5.Value = 1 Then  my_byte_value = my_byte_value + 16
    If Check6.Value = 1 Then  my_byte_value = my_byte_value + 32
    If Check7.Value = 1 Then  my_byte_value = my_byte_value + 64
    If Check8.Value = 1 Then  my_byte_value = my_byte_value + 128
    Best regards,

    Luciano

  4. #4
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Thank U Luciano.

    That was exactly what i wanted. Sorry for my ignorance.

    And if i am not asking for more can you also tell me how to reverse it.

    I am sure it would be simple , but still.

    Now how do i break up a byte to show up in the check boxes. Tick means One !

    Thank you steve. You have been a lot of help to me and one of my unsung hero's learnt a lot of programing skills from your inputs to different people on the Forum. I would surely send you a PM for that E-book

    regards

  5. #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.

  6. #6
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Thank You.

    Thank you once again. I hope this is helpful to other on the forum as well.

    regards

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 : 1

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