|
-
Sep 13th, 2000, 01:05 PM
#1
Thread Starter
Lively Member
Hi all,
I have a list box where if I click on text in it the text gets removed from the list box.
Now the problem is...
The lstbox is filled with data that must be saved to a record. I use a for do loop..
for i = 1 to lstBox-1 do
lstBox.listIndex = i
data1.recordset("stuff") = lstbox.text
next i
Now when the line lstbox.listindex is executed the computer somehow goes to my lstbox_Click sub. How do I stop it from throwing this click event while still setting the listindex to i. the problem is that when it goes to the click event the text is removed and then lstbox.text is empty.
help anyone
thanks in advance
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
-
Sep 13th, 2000, 01:10 PM
#2
_______
<?>
for delete I would use DblClick event.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 13th, 2000, 01:14 PM
#3
Fanatic Member
If you creating the program for yourself, I would go with HeSaidJoe. If you are creating it for end users, I would all a command button because end users might not know about the double click. It is better to have something visual for them.
Chemically Formulated As:
Dr. Nitro
-
Sep 13th, 2000, 01:15 PM
#4
_______
<?>
Code:
Option Explicit
Private Sub Command1_Click()
Open "C:\my documents\mytext.txt" For Output As #1
Dim i As Integer
For i = 0 To lstbox.ListCount - 1
lstbox.ListIndex = i
Print #1, lstbox.Text
Next
End Sub
Private Sub Form_Load()
Dim i
For i = 1 To 10
lstbox.AddItem i
Next i
End Sub
Private Sub lstbox_DblClick()
lstbox.RemoveItem (lstbox.ListIndex)
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 13th, 2000, 01:21 PM
#5
Fanatic Member
I had a similar problem with a DataGrid control and the RowColChange event. I ended up setting a flag before executing the loop. The click event would still be called, but would execute only when the flag was set.
Set up a boolean variable such as:
Global blnContinue as Boolean
And set it so it will be true:
blnContinue = True
And in your loop do this.
[code]
blnContinue=False
for i = 1 to lstBox-1 do
lstBox.listIndex = i
data1.recordset("stuff") = lstbox.text
next i
blnContinue=True
and in your click event:
[code]
Private Sub lstbox_click()
If blnContinue=False then exit sub
....
....
End Sub
Might not be the greatest solution, but it worked for me.
Good luck !
[Edited by jbart on 09-13-2000 at 02:24 PM]
-
Dec 10th, 2000, 10:58 PM
#6
New Member
I can't answer it but would like toask a question.
I have two list boxes whcih are the following.
lstChoices and lstNames.
lstChoices has items like
Full-Time
Full-Time/New Cars
Full-Time/Used Cars
New Cars
Part-Time
Part-Time/New Cars ; etc. these are loaded from form load
The lstNames list box has nothing in it. I am supposed to code the lstChoices control's click event so that it displays the appropriate listing of Names in the lstNames list box. The Names are in a .dat file on a disk on the a: drive. The book says . Hint: use the Instr function. The hint dosen't help me ; can you?
Thank You,
Mark
-
Dec 11th, 2000, 07:29 AM
#7
Addicted Member
I never use a loop like above.
You are all selecting the item by setting the listindex of the listbox.
I use the following (so you don't generate a click event at all)
Code:
For intIndex = 0 To (lstBox.ListCount - 1)
strKey = lstBox.List(intIndex)
Next
With the for loop you run through the listbox, with the lstBox.List(intIndex) you select the text in the listbox.
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
|