Results 1 to 8 of 8

Thread: check box code reduction help

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    I'm using the following code to uncheck/check a check box:

    Code:
    Private Sub picBPCredit_Click()
    
        '-- check/uncheck the checkbox
        If chkBPCredit.Value = 0 Then
            chkBPCredit.Value = 1
        Else
            chkBPCredit.Value = 0
        End If
        
    End Sub
    I know the above code can be reduced to 1 or 2 lines but I forgot how to do it.. The reduced code reads something like: "value of check box not equal to current value of check.." or something like that but I just can't figure it out..

    Any help would be appreciated..

    Dan

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    chkBPCredit.Value = - not(-chkBPCredit.Value)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    chkBPCredit.Value = IIf(chkBPCredit.Value = 0, 1, 0)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Immediate if's are slow, i've heard
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    allmost the same as kedaman's, for some people maybe more readable:

    chkBPCredit.Value = Abs(Not CBool(chkBPCredit.Value))

    regards

    Sascha

  6. #6
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    I try your code Kedaman cuz it's really short but it give me an error : Out of stack space.

    Why and what is stack space??

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Don't place it in chkBPCredit_Click, it will raise the same event over and over again until crashing.

    If you click it will automatically check/uncheck
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Oups!!!!
    I really need some sleep

    iiiihhaaaahh think i really need some sleep!

    oup i just repeat myself


    i think i ................

Posting Permissions

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



Click Here to Expand Forum to Full Width