Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > TRUE/FALSE convert to checkbox


Reply
 
Thread Tools Display Modes
  #1  
Old 12-09-2002, 08:34 AM
rkane
Guest
 
Posts: n/a
Question TRUE/FALSE convert to checkbox


I have a database value I'm pulling out that is a true or false.
I am wondering if there is a quick way to make that into a checkbox on a form.

I currently have the code checkbox.value = rs!inc
but since rs!inc returns true then it won't check the box.

Do I need to change inc to be a different type of field? Or how do I make this one statement work.

I'm still trying to learn the best way to do things so let me know what you all think.

Thanks for any help.
Reply With Quote
  #2  
Old 12-09-2002, 08:38 AM
Anis's Avatar
Anis Anis is offline
| Coder XXX |

Retired Leader
 
Join Date: Jun 2001
Location: Kuala Lumpur, Malaysia.
Posts: 3,018
Default

Code:
If rs!inc = True Then
check1.value = Checked
Endif
__________________
Regards,
Muhammad Anis Ur Rehman

Miles to go Before I Sleep.

http://www.projekcarpet.com/anis.html
Reply With Quote
  #3  
Old 12-09-2002, 08:49 AM
rkane
Guest
 
Posts: n/a
Default

Is there a way I can set it up so I don't have to do that.
I'm trying to model my database and program so that there is a direct correlation between each variable and each field, so if I have to change one or the other that is fine.
Reply With Quote
  #4  
Old 12-09-2002, 09:06 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,688
Default

Code:
' convert -1/0 to 1/0 check1.value = Not (rs!inc - 1)
Reply With Quote
  #5  
Old 12-09-2002, 09:11 AM
rkane
Guest
 
Posts: n/a
Default

ooer that did it. Thanks much.

Is there a checkbox.checked property?

Will the checkbox give me a 1 and 0 back when the user edits them? If so can I do a Not(checkbox.value +1) to convert from 1/0 to -1/0 or will I have to put an if statement in there to make it a true or false field?

And would I be better off just making it a number field with a value of 1 or 0?
Reply With Quote
  #6  
Old 12-09-2002, 09:20 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,688
Default

A boolean field will likely take less space, its probably not a big deal, but if there are a lot of them..

The code to go the other direction is the same:

Code:
rs!inc = Not (Check1.Value - 1)
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #7  
Old 12-09-2002, 10:03 AM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

Keep in mind, unlike an OptionButton, CheckBox.Value is not Boolean.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #8  
Old 12-09-2002, 10:21 AM
rkane
Guest
 
Posts: n/a
Default

Ok I just made it boolean. It is easier to save the data that way, and easier to retrieve it. Plus it makes for less code in the end.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->