-
January 20th, 2010, 04:25 PM
#1
Checkbox delete issue
Hey everyone, I'm having a little problem with my VB code. The program I am using is apart of a college project i have to create. Basically the search function within this program finds a person e.g. "Kari" and when the checkbox is clicked it should remove that person. However, the code for the checkbox is deleting the first record everytime and not the record selected, I was woundering if anyone could help me with the code?
Private Sub Check1_Click()
lst_name.ListIndex = 0
lst_surname.ListIndex = lst_name.ListIndex
lst_Pck_Point.ListIndex = lst_name.ListIndex
lst_Dest_Point.ListIndex = lst_name.ListIndex
lst_Times.ListIndex = lst_name.ListIndex
lst_name.RemoveItem lst_name.ListIndex
lst_surname.RemoveItem lst_surname.ListIndex
lst_Pck_Point.RemoveItem lst_Pck_Point.ListIndex
lst_Dest_Point.RemoveItem lst_Dest_Point.ListIndex
lst_Times.RemoveItem lst_Times.ListIndex
Check1.Value = 0
Check1.SetFocus
Check1.Value = 0
End Sub
-
January 20th, 2010, 04:44 PM
#2
Re: Checkbox delete issue
This statement tells it to use the first record.
Code:
lst_name.ListIndex = 0
Just DIM it first:
Code:
Dim LI As Integer
LI= lst_name.ListIndex
and use LI for the right value
Last edited by dglienna; January 20th, 2010 at 04:46 PM.
-
January 20th, 2010, 04:49 PM
#3
Re: Checkbox delete issue
do you mean something like that?
Dim ListIndex As Integer
ListIndex = lst_name.ListIndex
By the way i'm a noob so i'm not too sure on this
-
January 20th, 2010, 11:04 PM
#4
Re: Checkbox delete issue
That's a reserved word, so, no you can't. That's why I used LI instead.
Actually ListIndex = 0 should be a hint, but I'll tell you. Always use .ListIndex - 1, and check for -1 instead of 0
Last edited by dglienna; January 20th, 2010 at 11:07 PM.
Tags for this Thread
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
|