944,156 Members | Top Members by Rank

Ad:
Aug 30th, 2006
0

Issues with check boxes

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Stewie is offline Offline
30 posts
since Apr 2006
Aug 30th, 2006
0

Re: Issues with check boxes

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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Aug 31st, 2006
0

Re: Issues with check boxes

I was actually able to get the issue solved.
Thanks
Reputation Points: 10
Solved Threads: 0
Light Poster
Stewie is offline Offline
30 posts
since Apr 2006
Aug 31st, 2006
0

Re: Issues with check boxes

What was the solution? That way, should this problem arise again, we can have the fix available?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: visual basic 6 decompiler
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: making fields unupdateable in vb 5.0





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC