|
-
Oct 27th, 2001, 02:11 AM
#1
Thread Starter
Frenzied Member
Question From My Book
i have a question fom my vb book that i cant quit understand..can u help me solve it? it says
.....You have a form with two listbox controls on it. you have a textbox control to allow the ddate entry clerk to enter in the names. you have a button to add the names from the textnox to the first listbox. the first listbox could be set to multiselection to allow the company boss to select multiply names.you know hahow many items are in the list using the litcount property. you create a sub that taes an integerfor an argument representing the index of the list item. the sub then checks if this item in the first listbox has been selected copying it to the second listbox.....
-
Oct 27th, 2001, 03:19 AM
#2
PowerPoster
hi
I'm not quite sure what the question is asking ... I somehow doubt that u copied it word for word!! 
Anyway, maybe it is something like this???
Form has 1 textbox, 2 command buttons and 2 listboxes
Command 1 is to transfer data to list 1
Command 2 is to transfer highlighted items in list 1 to list 2
VB Code:
Option Explicit
Private Sub Command1_Click()
'Transfer text 1 to list 1
List1.AddItem Text1.Text
Text1.Text = ""
End Sub
Private Sub Command2_Click()
Dim lCounter As Integer
With List1
'Loop thru all items in list 1
For lCounter = 0 To .ListCount - 1
'If that item is highlighted
If .Selected(lCounter) Then
'Go to sub to check if it is already in list2
CheckPass lCounter
End If
Next
End With
End Sub
Private Sub CheckPass(lintItem As Integer)
Dim lCounter2 As Integer
Dim lFound As Boolean
With List2
If .ListCount = 0 Then
'No entries therefore must be no duplicates
.AddItem List1.List(lintItem)
Else
'Check list for duplicates
'NB there is an API call that does this in one go
'but will use loop for ease at this stage
For lCounter2 = 0 To .ListCount - 1
If List1.List(lintItem) = .List(lCounter2) Then
lFound = True
Exit For
End If
Next
If Not lFound Then .AddItem List1.List(lintItem)
End If
End With
End Sub
Regards
Stuart
-
Oct 27th, 2001, 03:21 AM
#3
Thread Starter
Frenzied Member
sorry i was just to lazy to type all of it sorry
-
Oct 27th, 2001, 03:22 AM
#4
Thread Starter
Frenzied Member
well, i think i knew how to do it i just wanted to know how to do it the way that they sayed to do it
-
Oct 27th, 2001, 03:23 AM
#5
PowerPoster
PS List 1 has Multiselect set to 1
Regards
Stuart
-
Oct 28th, 2001, 04:34 PM
#6
Thread Starter
Frenzied Member
thx but im still trying to figure out how THEY did it i really aready knew how im just trying to make sure i understand there way of doing it
-
Oct 28th, 2001, 04:51 PM
#7
PowerPoster
Confused
Hi
Does that mean that the problem is solved, case is closed? Or do u want to post their code and get help on certain bits?
Regards
stuart
-
Oct 28th, 2001, 05:33 PM
#8
Thread Starter
Frenzied Member
well i relly wanted some code for the question i asked at first and i c yoyrs but is dontnt seem like that was what they were asking me to do,, yours does thesame thing as theres but i just wanted to know how to do it there way
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
|