473,387 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB6 Checkbox fill all to true

I am working on a project for work and have been able to find most of my answers. This one still causes me issues. I am sure whatever it is Im doing wrong, it's simple.

I created a userform in VB6, placed Frame1 on it and then added 26 checkboxes (each one has its own code and is working) and 3 commandbuttons (ok, cancel, check all) on the frame. Everything is working the way i need it except the check all button. I have tried doing this several ways and just can't get anything to work.

After the command button "OK" is pressed it will run the code for each check box that = true. I also have a cancel command button that works.

I am trying to add a commandbutton/checkbox (have tried both) that will check but have been unsuccessful with either button or calls. I could do it the long way by setting each checkbox# = true, but never imagined this would take so long.


Current code (x is always false??):
Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton3_Click ()
  2. Dim x as Control
  3.  
  4. For each x in Userform1.Frame1.Controls
  5.    If TypeOf x is CheckBox then
  6.     x.value = true 
  7.    End if
  8. Next
  9. End Sub
Any help is appreciated.
Scott
Oct 1 '08 #1
5 4520
gwbob
14
try putting the code in the select all button to set the value on each check box to true so that they are all checked i think that might work
Oct 1 '08 #2
jg007
283 100+
I am not sure as I use .net but but should that not be ' x.checked = true ' and not x.value ?
Oct 2 '08 #3
I am not sure as I use .net but but should that not be ' x.checked = true ' and not x.value ?
The For loop runs itself 29 times (so that tells me it is running through each of the buttons/checkboxes). However Typeof X is never = to a checkbox so it doesn't get past that line to then goto the next line to change it. the X value must be passing something just not the correct way. Once I get that I will keep this in mind that I may have to change that piece to get it to actually change.


Thank you
Oct 3 '08 #4
try putting the code in the select all button to set the value on each check box to true so that they are all checked i think that might work

I think I understand what you mean. Which is what I did to get this pushed out to the user (since they don't see the code and only know if the checkboxes get checked or not)

Expand|Select|Wrap|Line Numbers
  1. Commandbutton3_Click()
  2.  
  3. Checkbox1.Value = True
  4. Checkbox2.Value = True...etc.
But everytime I add a new button with code I have to go back into the Commandbutton3 and add the new check box. this just makes it cumbersum instead of using some sort of For Loop.

Thanks

thanks
Oct 3 '08 #5
lee123
556 512MB
hello after reading your post i have done something i didn't see in your code and it works for me so if i was you i would try it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOK_Click()
  2. If cmdOK Then
  3.     Check1.Value = 1
  4.     Check2.Value = 1
  5.     Check3.Value = 1
  6.     Check4.Value = 1
  7. End If
  8. End Sub
as you can see this example will work you can put the rest of checkboxes in.

lee123
Oct 3 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Steph | last post by:
Hello, Can someone tell me the script to use for having a change on the same page when using checkbox function ? For example, i would to check one condition and display dynamically a button...
2
by: Martin | last post by:
Hi, Please can somebody explain how databinding is done on a checkbox list. I have the follwoing code which I would have thought was enough to databind a checkbox, but apparently not. The...
1
by: nicholas | last post by:
I am using Obout TreeView: www.obout.com I would like to implement a page to add and remove categories to a product with the Obout Treeview with checkboxes. Does anyone allready did this and...
2
by: Thomas A | last post by:
Hi ! I'm trying to use a datagrid with an checkbox column, I not shoure to get it work on several points I have got the rest of the data mapped to the grid but the checkbox doesnt work. 1....
4
by: magmo | last post by:
Hi I have created a windows form that hold a datagrid, that datagrid gets it values from a stored procedure. My problem is that I have added a checkbox to the datagrid and applied some style...
6
by: Bill Nguyen | last post by:
I need to add a checkbox in front of all the rows in a datagrid so that users can select/unselect them. Any help is greatly appreciated! Bill
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
3
by: uremog | last post by:
I have a set of of check boxes. onClick, the checkboxes call check_radio and recup_checkbox. the referenced radios function as group selectors. check_radio just unchecks the radios if someone...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.