| View previous topic :: View next topic |
| Author |
Message |
Golden Wing Grandmaster Cheater
Reputation: 0
Joined: 29 Aug 2007 Posts: 905
|
Posted: Sat Nov 10, 2007 11:38 am Post subject: How To Make A Simplelist Box |
|
|
language = vb6
how to make a list box you need:
| Code: |
1 listbox
3 command button
1 textbox |
name command1 cmdAdd and caption "add"
name command2 cmdRemove and caption remove
name command3 cmdClear and make caption clear
name text1 txtAdd and clear the text
put this code in cmdAdd:
| Code: | | list1.additem text1.text |
put this in cmdRemove:
put this in cmdClear:
or go to list1 select double click and put in list1.removeitem 0
their ya go
|
|
| Back to top |
|
 |
JakSplitter Expert Cheater
Reputation: 0
Joined: 31 Aug 2006 Posts: 196
|
Posted: Sat Nov 10, 2007 1:46 pm Post subject: |
|
|
| Good work, but it's not that hard to figure out, but good work anyways.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Nov 10, 2007 2:13 pm Post subject: |
|
|
xDemonRobbiex I'm actually proud of you. I remember when I was yelling at you with others for trying to do stuff way to advance, now your ploying your way through vb and even giving us tutorials, good ones at that. Way to go, + rep.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Golden Wing Grandmaster Cheater
Reputation: 0
Joined: 29 Aug 2007 Posts: 905
|
Posted: Sat Nov 10, 2007 2:56 pm Post subject: |
|
|
| oib111 wrote: | | xDemonRobbiex I'm actually proud of you. I remember when I was yelling at you with others for trying to do stuff way to advance, now your ploying your way through vb and even giving us tutorials, good ones at that. Way to go, + rep. | thx lol
|
|
| Back to top |
|
 |
goldengold Grandmaster Cheater Supreme
Reputation: -1
Joined: 11 Nov 2006 Posts: 1841 Location: -.-
|
Posted: Sat Nov 10, 2007 3:21 pm Post subject: |
|
|
though the down side is it's in VB
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Nov 10, 2007 4:47 pm Post subject: |
|
|
Uh, xDemonRobbiex, don't use List1.Remove 0 to remove an item, that will remove the first item in the listbox and not the selected item. To remove the selected item use:
| Code: | | List1.RemoveItem List1.ListIndex |
I also suggest you start reading up on error handling as things like this will cause errors over time. For example if the list is empty and you click a button it will error and kill the program unless you have proper error handling. To fix it for this case you can do something like:
| Code: | Private Sub cmdRemove_Click()
On Error GoTo ErrorHandle
'----------------------------------
' Check For Valid Item
'----------------------------------
If List1.ListIndex < 0 Then Exit Sub
'----------------------------------
' Remove Selected Item
'----------------------------------
List1.RemoveItem List1.ListIndex
Exit Sub
ErrorHandle:
MsgBox Err.Description, vbCritical, "Error: " & Err.Number
End Sub |
This way, first it checks if the ListIndex is less then 0, if so then exit the sub and do nothing. When the index is invalid, the return is -1. Next it will remove the selected item and exit the sub. (Note the Exit Sub, it is needed or it will call the ErrorHandle still.)
If an error occurs, 'On Error Goto ErrorHandle' tells the function/sub to goto the label 'ErrorHandle' which in this case is a message box to return the error description and number.
_________________
- Retired. |
|
| Back to top |
|
 |
oddmidge Cheater
Reputation: 0
Joined: 09 Nov 2007 Posts: 40 Location: Melbourne Australia
|
Posted: Sat Nov 10, 2007 4:47 pm Post subject: |
|
|
Do any of use no the link for VB6 download i no its illegal but im only 12 and cant buy it
_________________
this is a signature part of my name which appears in all my post  |
|
| Back to top |
|
 |
Golden Wing Grandmaster Cheater
Reputation: 0
Joined: 29 Aug 2007 Posts: 905
|
Posted: Sat Nov 10, 2007 5:09 pm Post subject: |
|
|
| Wiccaan wrote: | Uh, xDemonRobbiex, don't use List1.Remove 0 to remove an item, that will remove the first item in the listbox and not the selected item. To remove the selected item use:
| Code: | | List1.RemoveItem List1.ListIndex |
I also suggest you start reading up on error handling as things like this will cause errors over time. For example if the list is empty and you click a button it will error and kill the program unless you have proper error handling. To fix it for this case you can do something like:
| Code: | Private Sub cmdRemove_Click()
On Error GoTo ErrorHandle
'----------------------------------
' Check For Valid Item
'----------------------------------
If List1.ListIndex < 0 Then Exit Sub
'----------------------------------
' Remove Selected Item
'----------------------------------
List1.RemoveItem List1.ListIndex
Exit Sub
ErrorHandle:
MsgBox Err.Description, vbCritical, "Error: " & Err.Number
End Sub |
This way, first it checks if the ListIndex is less then 0, if so then exit the sub and do nothing. When the index is invalid, the return is -1. Next it will remove the selected item and exit the sub. (Note the Exit Sub, it is needed or it will call the ErrorHandle still.)
If an error occurs, 'On Error Goto ErrorHandle' tells the function/sub to goto the label 'ErrorHandle' which in this case is a message box to return the error description and number. |
yea thx i had trouble with that
|
|
| Back to top |
|
 |
|