|
|
#1 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
I have made this progam that picks random things from two lists and displays them on a form. I was wondering if there is a way i can have it so when i check a check box labled one of the items in one of the lists will not show up anymore.
|
|
|
|
|
|
#2 |
|
Hyperactive Member
Join Date: Dec 05
Location: Toronto, Canada
Posts: 356
![]() |
Re: check box to remove items from list?
How are you displaying the items??? In a listbox, combobox ....????
__________________
Hey... If you found this post helpful please rate it.
|
|
|
|
|
|
#3 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
im displaying them in a lable.
|
|
|
|
|
|
#4 |
|
Hyperactive Member
Join Date: Dec 05
Location: Toronto, Canada
Posts: 356
![]() |
Re: check box to remove items from list?
Well since you are using a label, it gets complicated.
1. First you gotta use the InStr function to find where the string you want to remove is at in the labels caption. 2. Once you get the start number of that string, you use the Left function to take apart everything from before the string you want to remove and assign it to a temporary variable 3. You can use the Len function to find the length of the string you want to remove and add that to the starting value from Step 2 and then use the Right function to take everything from after the string you want to remove and assign it to another temporary variable. 4. Now combine the first and the second variable and display in the label. I'll try to post the code... but if you can do it on your own... good for you Khanjan
__________________
Hey... If you found this post helpful please rate it.
Last edited by khanjan_a2k; Jan 30th, 2007 at 07:16 PM. |
|
|
|
|
|
#5 |
|
Hyperactive Member
Join Date: Dec 05
Location: Toronto, Canada
Posts: 356
![]() |
Re: check box to remove items from list?
I think this should work... however I am missing a space somewhere in the final output... anyways this is a sample, you maybe be able to use it...
VB Code:
Or you could try loading each and every item into an array and then load it into the label. And if you want to remove an item, just don't display that string array. Its much easier!!!!!!!! Ask if you want a sample
__________________
Hey... If you found this post helpful please rate it.
|
|
|
|
|
|
#6 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
can i have a smaple of the easier way, im pretty new to this and the first example goes waaaay over my head. thanks for you help though.
|
|
|
|
|
|
#7 |
|
Addicted Member
Join Date: Jan 07
Location: England
Posts: 228
![]() |
Re: check box to remove items from list?
step through that code, it will become clearer
|
|
|
|
|
|
#8 |
|
Re: check box to remove items from list?
You could also put your project in a zip file and attach it to a post so we could look at it.
__________________
Tips, Examples & Tutorials: A valuable forum tool • Generate unique TreeView keys • TreeView with "open" and "closed folder" icons • Time code using GetTickCount • How to trap the Tab key • Scroll a form • NumberBox ActiveX control • Color a ListView row • An InputBox form • How to use SaveSetting and GetSetting • A program registration scheme • Spellcheck a Textbox • Resize controls • Open Windows Explorer at Last Visited Path • A Blackjack Game • Count lines of code • Private Message Viewer • Copy/Paste VB Code • Paste VB Code Add-In • Insert Procedure Names Add-In • A calculator for the game of Spider • My review of REALbasic 2008 • VB6 Debug Tutorial • Picture Viewer • VBF Photo Contest Winners Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer. If someone helped you today then please consider rating their post. |
|
|
|
|
|
|
#9 |
|
Hyperactive Member
Join Date: Dec 05
Location: Toronto, Canada
Posts: 356
![]() |
Re: check box to remove items from list?
Well... I did come up with the code but there is a little or big bug in there somewhere... I am losing the count of the arrays in there somewhere.... However, if you don't really care about each of those items throughout the rest of the program and really aren't tracking each item individually, then just use the first piece of code... the second one is if you want to track each item individually....
Anyways I have attached the second "prototype"... see if you can find the bug... I bet steve will appreciate it Khanjan
__________________
Hey... If you found this post helpful please rate it.
|
|
|
|
|
|
#10 |
|
Re: check box to remove items from list?
Do you have to use a label to display the array? Why not a Listbox? In any case please tell me the exact steps to reproduce the problem and specifically what the problem is.
__________________
Tips, Examples & Tutorials: A valuable forum tool • Generate unique TreeView keys • TreeView with "open" and "closed folder" icons • Time code using GetTickCount • How to trap the Tab key • Scroll a form • NumberBox ActiveX control • Color a ListView row • An InputBox form • How to use SaveSetting and GetSetting • A program registration scheme • Spellcheck a Textbox • Resize controls • Open Windows Explorer at Last Visited Path • A Blackjack Game • Count lines of code • Private Message Viewer • Copy/Paste VB Code • Paste VB Code Add-In • Insert Procedure Names Add-In • A calculator for the game of Spider • My review of REALbasic 2008 • VB6 Debug Tutorial • Picture Viewer • VBF Photo Contest Winners Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer. If someone helped you today then please consider rating their post. |
|
|
|
|
|
|
#11 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
Thats a neat little sample, thanks. However it is not really what im looking for. I never really explained it well enough. It is a randomizing program that when you click the "GO!" button, it will pick one word from one list, and one word from another list. The first word will appear in the first label, and the second word in the second label. I want to have a list of check boxes that are labeled the words in the list. ie each word has its own check box, then when the check box is checked, the word it represents is not an option to come up in the respective label. I think that is a much better explanation.
|
|
|
|
|
|
#12 | |
|
Hyperactive Member
Join Date: Dec 05
Location: Toronto, Canada
Posts: 356
![]() |
Re: check box to remove items from list?
Quote:
Khanjan
__________________
Hey... If you found this post helpful please rate it.
|
|
|
|
|
|
|
#13 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
There are 2 lists and 2 labels. i'll call them "list a" and "list b". The lists are in the code and the user cannot see them. The program will select one word from "list a" and one word from "list b" and put them in "label a" and "label b". I want to make it so i have a checkbox for each word from "list a" and a check box for each word in "list b", and when the user clicks the checkbox, it disables one word from the list, so it will not appear in the label. i think that should help. if not ill put my whole project there.
|
|
|
|
|
|
#14 |
|
Hyperactive Member
Join Date: Dec 05
Location: Toronto, Canada
Posts: 356
![]() |
Re: check box to remove items from list?
Ok about the lists... I'll tell you what... the easiest and most effiecient way for this is to use a listbox control, change its Style property to 1 - Checkbox... This gives you are checkbox for each of the items in the listbox... The rest... I hope you know how to use a listbox lol...
Khanjan
__________________
Hey... If you found this post helpful please rate it.
|
|
|
|
|
|
#15 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
Thanks, i have an idea and i think it may work. Thanks for all your help.
|
|
|
|
|
|
#16 |
|
Addicted Member
Join Date: Jan 07
Location: England
Posts: 228
![]() |
Re: check box to remove items from list?
could you not use checkbox on change
then put VB Code:
or am i missing the point? |
|
|
|
|
|
#17 | |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
Quote:
|
|
|
|
|
|
|
#18 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
im not really sure what i should do.
VB Code:
i also just tried this but it didnt work. VB Code:
I have the lists load with the form, like this VB Code:
Last edited by stevevb6; Jan 31st, 2007 at 12:07 PM. |
|
|
|
|
|
#19 |
|
Re: check box to remove items from list?
You can't remove an item from a listview based solely on it's value. You need to know the index of the value. The following does that. I go through the list backward in case there is more than one entry with the same value.
VB Code:
__________________
Tips, Examples & Tutorials: A valuable forum tool • Generate unique TreeView keys • TreeView with "open" and "closed folder" icons • Time code using GetTickCount • How to trap the Tab key • Scroll a form • NumberBox ActiveX control • Color a ListView row • An InputBox form • How to use SaveSetting and GetSetting • A program registration scheme • Spellcheck a Textbox • Resize controls • Open Windows Explorer at Last Visited Path • A Blackjack Game • Count lines of code • Private Message Viewer • Copy/Paste VB Code • Paste VB Code Add-In • Insert Procedure Names Add-In • A calculator for the game of Spider • My review of REALbasic 2008 • VB6 Debug Tutorial • Picture Viewer • VBF Photo Contest Winners Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer. If someone helped you today then please consider rating their post. |
|
|
|
|
|
|
#20 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
Do i just replace what i have with that?
VB Code:
|
|
|
|
|
|
#21 |
|
Re: check box to remove items from list?
Yes, and of course the line
If List1.List(lngIndex) = "AAA" Then could be changed to something like If List1.List(lngIndex) = Text1.Text Then
__________________
Tips, Examples & Tutorials: A valuable forum tool • Generate unique TreeView keys • TreeView with "open" and "closed folder" icons • Time code using GetTickCount • How to trap the Tab key • Scroll a form • NumberBox ActiveX control • Color a ListView row • An InputBox form • How to use SaveSetting and GetSetting • A program registration scheme • Spellcheck a Textbox • Resize controls • Open Windows Explorer at Last Visited Path • A Blackjack Game • Count lines of code • Private Message Viewer • Copy/Paste VB Code • Paste VB Code Add-In • Insert Procedure Names Add-In • A calculator for the game of Spider • My review of REALbasic 2008 • VB6 Debug Tutorial • Picture Viewer • VBF Photo Contest Winners Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer. If someone helped you today then please consider rating their post. |
|
|
|
|
|
|
#22 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
it isnt going to work for what i want it for. that code removes the item from the list, and when the checkbox is unchecked, it does not come back. i need something to make the program randomize again when the label1.caption = the caption of the check box, only when the checkbox.value = true.
Last edited by stevevb6; Jan 31st, 2007 at 01:11 PM. |
|
|
|
|
|
#23 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
how can i add an item to the list by clicking the check box,
like this? VB Code:
|
|
|
|
|
|
#24 |
|
Re: check box to remove items from list?
Try something like this
VB Code:
And then in the Click sub List1.AddItem mstrSave
__________________
Tips, Examples & Tutorials: A valuable forum tool • Generate unique TreeView keys • TreeView with "open" and "closed folder" icons • Time code using GetTickCount • How to trap the Tab key • Scroll a form • NumberBox ActiveX control • Color a ListView row • An InputBox form • How to use SaveSetting and GetSetting • A program registration scheme • Spellcheck a Textbox • Resize controls • Open Windows Explorer at Last Visited Path • A Blackjack Game • Count lines of code • Private Message Viewer • Copy/Paste VB Code • Paste VB Code Add-In • Insert Procedure Names Add-In • A calculator for the game of Spider • My review of REALbasic 2008 • VB6 Debug Tutorial • Picture Viewer • VBF Photo Contest Winners Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer. If someone helped you today then please consider rating their post. |
|
|
|
|
|
|
#25 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
http://hx.pri.ee/dsrc/dice.php
this is actually very close to the program i want to make. It is for a game that i play, some guy wanted it on the forum of the site and i figured it is a good way to get some vb6 skills. Last edited by stevevb6; Jan 31st, 2007 at 03:49 PM. |
|
|
|
|
|
#26 |
|
Lively Member
Join Date: Jan 07
Posts: 93
![]() |
Re: check box to remove items from list?
i got this one on my own. i used this code.
VB Code:
VB Code:
Last edited by stevevb6; Feb 2nd, 2007 at 08:36 AM. |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|