Results 1 to 8 of 8

Thread: Question From My Book

  1. #1

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211

    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.....

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     'Transfer text 1 to list 1
    5.     List1.AddItem Text1.Text
    6.     Text1.Text = ""
    7. End Sub
    8.  
    9. Private Sub Command2_Click()
    10.     Dim lCounter As Integer
    11.     With List1
    12.         'Loop thru all items in list 1
    13.         For lCounter = 0 To .ListCount - 1
    14.             'If that item is highlighted
    15.             If .Selected(lCounter) Then
    16.                 'Go to sub to check if it is already in list2
    17.                 CheckPass lCounter
    18.             End If
    19.         Next
    20.     End With
    21. End Sub
    22.  
    23. Private Sub CheckPass(lintItem As Integer)
    24.     Dim lCounter2 As Integer
    25.     Dim lFound As Boolean
    26.     With List2
    27.         If .ListCount = 0 Then
    28.             'No entries therefore must be no duplicates
    29.             .AddItem List1.List(lintItem)
    30.         Else
    31.             'Check list for duplicates
    32.             'NB there is an API call that does this in one go
    33.             'but will use loop for ease at this stage
    34.             For lCounter2 = 0 To .ListCount - 1
    35.                 If List1.List(lintItem) = .List(lCounter2) Then
    36.                          lFound = True
    37.                          Exit For
    38.                  End If
    39.             Next
    40.             If Not lFound Then .AddItem List1.List(lintItem)
    41.         End If
    42.     End With
    43. End Sub
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  3. #3

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    sorry i was just to lazy to type all of it sorry

  4. #4

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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

  5. #5
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    PS List 1 has Multiselect set to 1
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  6. #6

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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

  7. #7
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274

    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
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  8. #8

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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
  •  



Click Here to Expand Forum to Full Width