Results 1 to 6 of 6

Thread: [RESOLVED] stop items duplicating

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    18

    Resolved [RESOLVED] stop items duplicating

    I have a project due for college tomorrow,its an IT job finder project..so far I've coded the command buttons,textboxes,checkboxes etc,so anything the user inputs on form1 will be printed off on form 2...

    Im stuck on the listbox and combo box ......I have 1 combobox which displays three jobtypes ...Permanent,Full time and Part time,once the user clicks on any of these a listbox with 5 jobtitles should appear in the listbox to the right of the combo box....

    VB Code:
    1. Private Sub Cbojobtype_Click()
    2. If Cbojobtype.Text = "Full Time" Then
    3. lstjobtitle1.AddItem "IT Manager"
    4. lstjobtitle1.AddItem "IT Sales Executive"
    5. lstjobtitle1.AddItem "IT Field Technican"
    6. lstjobtitle1.AddItem "IT Procedure Director"
    7. lstjobtitle1.AddItem "IT Director"
    8.  
    9. ElseIf Cbojobtype.Text = "Contract" Then
    10. lstjobtitle1.AddItem "IT Auditor"
    11. lstjobtitle1.AddItem "IT Project Manager"
    12. lstjobtitle1.AddItem "Operations & IT Coordinator"
    13. lstjobtitle1.AddItem "Service & Support Manager"
    14. lstjobtitle1.AddItem "Senior Engineering Manager"
    15.  
    16.  
    17. ElseIf Cbojobtype.Text = "Part Time" Then
    18. lstjobtitle1.AddItem "Ecommerce consultant"
    19. lstjobtitle1.AddItem "Network Engineer"
    20. lstjobtitle1.AddItem "Programmer"
    21. lstjobtitle1.AddItem "Test Analyst"
    22. lstjobtitle1.AddItem "QA Manager"
    23.  
    24. End If
    25. End Sub
    26.  
    27. Private Sub Form_Load()
    28. Cbojobtype.AddItem "Contract"
    29. Cbojobtype.AddItem "Full time"
    30. Cbojobtype.AddItem "Part Time"
    31. End Sub


    my problem is that when i click on say Contract for example....the 5 jobtitles appear fine in the listbox..but if i click contract again..the items for contract duplicate ...so I end up with

    IT Auditor
    IT Project Manager
    Operations & IT Coordinator
    Service & Support Manager
    Senior Engineering Manager
    IT Auditor
    IT Project Manager
    Operations & IT Coordinator
    Service & Support Manager
    Senior Engineering Manager

    items repeat over and over again........

    so my question would be how would i stop these items duplicating?...and how would i go about clearing a listbox when i switch over to another jobtype..like permanent...because contract jobtitles remain when i switch...

    (ps)ive only been using VB6 for about 3 weeks now,so I apologise for my lack of knowledge...

    thanks for anyones input.
    Last edited by MartinLiss; Oct 8th, 2006 at 01:04 PM.

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: stop items duplicating

    Welcome to VBForums!

    You'll have to clear the list before adding new items:
    VB Code:
    1. Private Sub Cbojobtype_Click()
    2.     [B]Cbojobtype.Clear[/B]
    3.         If '...

  3. #3

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    18

    Re: stop items duplicating

    Martin sorry for not using vbcode tags,I will in future..

    Gavio...thank you very much for the reply ,Im not really sure how to code that..tbh .but I'll play with it for a few more hours...thanks though I appreciate the help.

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [RESOLVED] stop items duplicating

    what gavio meant was:
    VB Code:
    1. Private Sub Cbojobtype_Click()
    2.     [B]lstjobtitle1[/B].Clear
    3.     If Cbojobtype.Text = "Full Time" Then
    4.         'etc.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    18

    Talking Re: [RESOLVED] stop items duplicating

    VB Code:
    1. Private Sub cboJobType_Click()
    2.       lstJobTitle.Clear '====Clears the list before adding items===='
    3.  
    4. If cboJobType.Text = "FULL TIME" Then
    5.  
    6.       lstJobTitle.AddItem "IT Manager"
    7.       lstJobTitle.AddItem "IT Sales executive"
    8.       lstJobTitle.AddItem "IT Field technican"
    9.       lstJobTitle.AddItem "IT Procedure director"
    10.       lstJobTitle.AddItem "IT Director"
    11.      
    12.  
    13.    ElseIf cboJobType.Text = "CONTRACT" Then
    14.      
    15.       lstJobTitle.AddItem "IT Auditor"
    16.       lstJobTitle.AddItem "IT Project Manager"
    17.       lstJobTitle.AddItem "Operations & IT Coordinator"
    18.       lstJobTitle.AddItem "Service & Support Manager"
    19.       lstJobTitle.AddItem "Senior Engineering Manager"
    20.      
    21.      
    22.    ElseIf cboJobType.Text = "PART TIME" Then
    23.      
    24.       lstJobTitle.AddItem "Ecommerce consultant"
    25.       lstJobTitle.AddItem "Network Engineer"
    26.       lstJobTitle.AddItem "Programmer"
    27.       lstJobTitle.AddItem "Test Analyst"
    28.       lstJobTitle.AddItem "QA Manager"
    29.          
    30.  
    31.    
    32. End If    
    33. End Sub

    thanks bushmobile...I think I got it now..

    thanks for everyones help
    much appreciated

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