Jump to content
Sign in to follow this  
Anonymouse

If Checked Then, If Not Checked Then,

Recommended Posts

Anonymouse

$CheckRY1= BitAnd(GUICtrlRead($CheckR[0]),$GUI_CHECKED)
    $CheckRN1= BitAnd(GUICtrlRead($CheckR[0]),$GUI_UNCHECKED)
    
Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\Nicker\Desktop\template.xls", 0, False)

    If $CheckR[0] = $CheckRY1 Then
        _ExcelWriteCell($oExcel, $PAU0, 13, 9)
    ElseIf $CheckR[0] = $CheckRN1 Then
        _ExcelWriteCell($oExcel, $PAU0, 13, 1)

This reads the checkbox correctly, but it doesnt write in cell I-13. Am I missing something here?


children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)

Share this post


Link to post
Share on other sites
Valik

This is some seriously retarded code. Let's break it down and see why.

$CheckRY1= BitAnd(GUICtrlRead($CheckR[0]),$GUI_CHECKED)
   $CheckRN1= BitAnd(GUICtrlRead($CheckR[0]),$GUI_UNCHECKED)

Why are you explicitly checking for unchecked? The opposite of checked is unchecked, do you have to test that if you've already done the checked test?

If $CheckR[0] = $CheckRY1 Then
               _ExcelWriteCell($oExcel, $PAU0, 13, 9)
           ElseIf $CheckR[0] = $CheckRN1 Then
               _ExcelWriteCell($oExcel, $PAU0, 13, 1)

This is bad on a lot of levels. First, once again, you're *trying* to do the "If Checked ElseIf Unchecked" stupidity. But second, you're comparing a boolean value to the control ID. I don't know what perverse logic made you think that'd ever work.

Here's something that should resemble working code:

Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\Nicker\Desktop\template.xls", 0, False)
     
         If BitAnd(GUICtrlRead($CheckR[0]),$GUI_CHECKED) Then
             _ExcelWriteCell($oExcel, $PAU0, 13, 9)
         Else
             _ExcelWriteCell($oExcel, $PAU0, 13, 1)
         EndIf

Think about your code. Work through the logic. What you were trying to do is incredibly simple and you over-complicated it by about a thousand. And then when it didn't work you didn't bother trying to think through the logic.

Share this post


Link to post
Share on other sites
Anonymouse

This is some seriously retarded code. Let's break it down and see why.

$CheckRY1= BitAnd(GUICtrlRead($CheckR[0]),$GUI_CHECKED)
   $CheckRN1= BitAnd(GUICtrlRead($CheckR[0]),$GUI_UNCHECKED)

Why are you explicitly checking for unchecked? The opposite of checked is unchecked, do you have to test that if you've already done the checked test?

If $CheckR[0] = $CheckRY1 Then
               _ExcelWriteCell($oExcel, $PAU0, 13, 9)
           ElseIf $CheckR[0] = $CheckRN1 Then
               _ExcelWriteCell($oExcel, $PAU0, 13, 1)

This is bad on a lot of levels. First, once again, you're *trying* to do the "If Checked ElseIf Unchecked" stupidity. But second, you're comparing a boolean value to the control ID. I don't know what perverse logic made you think that'd ever work.

Here's something that should resemble working code:

Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\Nicker\Desktop\template.xls", 0, False)
     
         If BitAnd(GUICtrlRead($CheckR[0]),$GUI_CHECKED) Then
             _ExcelWriteCell($oExcel, $PAU0, 13, 9)
         Else
             _ExcelWriteCell($oExcel, $PAU0, 13, 1)
         EndIf

Think about your code. Work through the logic. What you were trying to do is incredibly simple and you over-complicated it by about a thousand. And then when it didn't work you didn't bother trying to think through the logic.

:duh: .. I am also checking if a radio button is checked, though. So there are 4 different options, Check1 Radio1, Check1 Radio2, Check2 Radio1, Check2 Radio2. So I will have to check all values... but I don't know what I was thinking with assigning variables to it. I like to make things a lot harder than they actually are, I guess. I also presume this is why you are a designer and I'm a noob. :) Thank you, valik. Now that I put it that way though, I don't know why I am even using checkboxes, I should just have 4 radios set in two separate groups.

[edit]

You're right I'm an idiot.. why not just have 4 radios and each one be one value instead of being able to select two of each... Thank you for forcing me to actually rub a few brain cells together.

[/edit]

Edited by Anonymouse

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.