Issues with check boxes

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Apr 2006
Posts: 30
Reputation: Stewie is an unknown quantity at this point 
Solved Threads: 0
Stewie Stewie is offline Offline
Light Poster

Issues with check boxes

 
0
  #1
Aug 30th, 2006
As far as I know when a check box is check the value should be 1 and when it is not checked it should be 0 correct?

In my case if I don't check the box its null and if I do its -1

Here is my code

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub AddGeneral()
  2. Dim rsAdd As Recordset
  3. Dim sql As String
  4.  
  5. If (chk1.checkstate = 1 And chk2.checkstate = 1) Then
  6. Kidney = "Both"
  7. MsgBox "Checked"
  8. ElseIf (chk1.Value = 1 And chk2.Value = "") Then
  9. Kidney = "Self"
  10. ElseIf (chk1.Value = "" And chk2.Value = 1) Then
  11. Kidney = "Family"
  12. Else
  13. Kidney = ""
  14. End If
  15.  
  16. If (chk3.Value = 1 And chk4.Value = 1) Then
  17. Head = "Both"
  18. ElseIf (chk3.Value = 1 And chk4.Value = 0) Then
  19. Head = "Self"
  20. ElseIf (chk3.Value = 0 And chk4.Value = 1) Then
  21. Head = "Family"
  22. Else
  23. Head = ""
  24. End If


now i put -1 for the values and it worked but if i didnt check them some were 0 and some were null
if i have both check boxes checked it works
returns -1 for both
but if i just check one of the boxes it returns -1 and Null

ive tried -1 and Null, -1 and "", -1 and 0
Last edited by Stewie; Aug 30th, 2006 at 12:59 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Issues with check boxes

 
0
  #2
Aug 30th, 2006
I can't really tell by your code, but is this VB express, .NET, or Legacy (VB 4, 5, or 6)? If it's Legacy VB, could you attach the project in a .zip to your next post, so that I can download your code, and see your problem. The truth is, I can't even replicate your error. I'm guessing, since vb6 doesn't have a .checkstate property for checkboxes, that it's not VB6. Something to check, and I see (based on your question) why you would have done this, but you are testing the checkboxes .value property against an empty string (""). Something to consider, would be testing against vbnull or vbnullstring.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 30
Reputation: Stewie is an unknown quantity at this point 
Solved Threads: 0
Stewie Stewie is offline Offline
Light Poster

Re: Issues with check boxes

 
0
  #3
Aug 31st, 2006
I was actually able to get the issue solved.
Thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Issues with check boxes

 
0
  #4
Aug 31st, 2006
What was the solution? That way, should this problem arise again, we can have the fix available?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC