Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selected CheckBoxes in const Bits

Status
Not open for further replies.

Huskey

Vendor
Aug 23, 2002
53
GB
Hi there,

I am required to select a list of table name using a checkboxes. The selected table name (if check = 1), will be stored in a vector defined as const Bits. How am I supposed to store in a const Bits??? I have been struggling for few days to find out the way.

const Bits tableselected;
For (int j = 0; j < tablenames.size(); j++) {
tableselected[j] == m_ctrlCheckListBox.GetCheck(j);
};

It does not work!!! Please help!! Thanks very much!!!



 
Hi Huskey,

More information required : Is it a Compile problem ... or what ?

Could it be the 'const' in :

const Bits tableselected;

Constant variables cannot be changed after initialisation so this should give you a compiler error.

/JOlesen
 
Dear JOlesen,

Thank you for your reply. This is not the compilation problem or something. In fact, I want to pass the number of selected tables into a vector defined as const bits. By identifying the state of the checkboxes, I know which one should be selected or which one is not. So, all these will pass to the vector that hold the value. I was trying to define in this way:

const Bits tableselected;
For (int j = 0; j < tablenames.size(); j++) {
tableselected[j] == m_ctrlCheckListBox.GetCheck(j);
};

But, I always receive the error telling me that the selected tables is NULL even I have selected all the checkboxes of the table names.

How am I supposed to store in a const Bits??? I have been struggling for few days to find the solution.

in another part of the program, it was defined as folows to extract the information about which table is selected:

for (i = 0; i < selected.GetSize(); i++) {
// Skip non-selected columns.
if (!selected)
continue;

........
}

Please help!! Thanks very much!!!



 
Hi Huskey,

I Think I get a little closer to your problem :

You are doing a comparison instead of an assignment .. this seems like an error to me :


tableselected[j] == m_ctrlCheckListBox.GetCheck(j);
should be
tableselected[j] = m_ctrlCheckListBox.GetCheck(j);


const Bits .... What's this ?? ... and why const ??

/JOlesen

 
Huskey,

Another thing :

If the codesnippet is accurate I think you have a few more problems (Since GetCheck() returns an int, I assume 'tableselected' is a vector<int>, although you use the name 'Bits')

Advise :
1) Remove the const
2) You need to be sure that vector contains the right number of elements to hold the values - or you should code the line like this :

Bits.push_back(m_ctrlCheckListBox.GetCheck(j));

This will allocate the element(s).


/JOlesen
 
Dear JOlesen,

Thank you for your help again. The file is actually defined in const Bits. The &quot;bits&quot; is a vector but not a vector<int>. It provides a compact representation of the set {0, . . . , n&#8722;1}, useful if n is not too high and the average set cardinality is not too low. (Otherwise, consider using an integer vector instead.) Offers efficient methods for set union, intersection, difference, subset testing, etc.

Do you have any email address and I can send you the header & cpp file. The reason of going through all this stuff is because I am trying to make use of someone's library which has to comply with his structure.

Please help if possible. Many thanks!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top