|
-
Aug 10th, 2012, 03:36 AM
#1
Thread Starter
Member
direct me somewhere
can anyone tell me or link me to what i should be reading up on when it comes to adding and removing items on a list from a listbox. like have a textfield where i type something, click a button. it's added to the list. and beside the add button, it removes what i have selected in the list. the listbox will also be loaded from a .txt document if that means anything.
thanks in advance.
-
Aug 10th, 2012, 04:57 AM
#2
Re: direct me somewhere
it is probably
Code:
list1.removeitem list1.listindex
fixed
Last edited by westconn1; Aug 11th, 2012 at 02:50 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 11th, 2012, 12:02 AM
#3
Re: direct me somewhere
Use this
Code:
'~~> Add Item
Private Sub Command1_Click()
List1.AddItem Text1.Text
End Sub
'~~> Remove Selected Item
Private Sub Command2_Click()
List1.RemoveItem (List1.ListIndex)
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 11th, 2012, 09:59 AM
#4
Re: direct me somewhere
Avoid falling into this odd habit though:
Code:
Private Sub Command2_Click()
List1.RemoveItem (List1.ListIndex)
End Sub
Those parentheses are incorrect, and can have nasty unexpected side effects if you don't understand what your use of them is asking the compiler to do. They are not innocuous, though you might get away with it 80% of the time.
This is a sort of "creeping crud" that happens when people use The Great Pretender (VB.Net) for a while, where Anders and Friends decided to warp decades-old Microsoft Basic syntax.
What you want here is:
Code:
Private Sub Command2_Click()
List1.RemoveItem List1.ListIndex
End Sub
-
Aug 11th, 2012, 12:47 PM
#5
Re: direct me somewhere
Reading from the .txt document depends on how it is written inside... Is it one entry for each line or is the entries seperates with a coma ","
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|