Combo Box Comparison


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Combo Box Comparison

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Combo Box Comparison

    [Originally posted by Terry Ward]

    What is the best or efficient way of performing combobox item comparisons and storing its negative results?

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Combo Box Comparison

    [Originally posted by Greg DeBacker]

    Can you be more specific? Are you trying to compare two ComboBoxes with each other, or compare all of the items in one ComboBox with each other? And what do you mean by "storing its negative results"?

    Grex

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Combo Box Comparison

    [Originally posted by Terry Ward]

    I would like to compare all of the items against items in another combo box. When this happens, only 800 of 4752 items gets compared and then the comparison routine stops running.

    Combo6 has 4500 items
    Combo1 has 4752 items


    Private Sub MoveExToHT()
    Dim nExchange, nHeat, i, j, Cmp, nResults As Integer
    Dim vEName, vHName As String

    Command3.Caption = "Now, removing correct e-mails"

    Screen.MousePointer = vbHourglass

    nResults = 0

    Results.Clear

    ' Count EXCHANGE (Combo6) and HEAT (Combo1) table name items
    nExchange = Combo6.ListCount
    nHeat = Combo1.ListCount

    'Debug.Print "nHEAT: " & nHeat & " nExchange: " & nExchange

    'Compare HEAT names to EXCHANGE names and replace with correct email address
    For i = 0 To nHeat - 1
    vHName = Combo6.List(i)
    For j = 0 To nExchange
    Cmp = StrComp(vHName, Combo1.List(j), vbTextCompare)

    'Debug.Print "COMPARE: " & Cmp & " " & vHName & " " & Combo1.List(j)

    If Cmp = 0 Then
    nResults = nResults + 1
    StatusBar1.Panels(1).Text = "Moving correct Exchange Data to HEAT: " & nResults
    Label5.Caption = nResults
    Combo7.List(i) = Combo5.List(i)
    Exit For
    End If
    Next j
    Next i

    Screen.MousePointer = vbNormal

    Command3.Caption = "Completed moving correct Exchange Data to HEAT!"

    End Sub

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Combo Box Comparison

    [Originally posted by Greg DeBacker]

    I see a couple of possible problems.

    First off, this does not work in VB as it does in C...

    Dim nExchange, nHeat, i, j, Cmp, nResults As Integer
    Dim vEName, vHName As String

    Here, only, 'nResults' is explicitly declared as an Integer, and only 'vHName' is explicitly declared as a String. In VB everything needs its own explicit data type unless you use one or more of the DefType statements in the declarations section, but I would stay away from that. This is probably not causing a problem because the non-declared variables are Variants. I just thought I would point it out.

    You have no error handleing and no 'On Error Resume Next' but if the routine that calles this sub has something like that it might be hiding any errors you are getting. Comment out any 'On Error...' statments in the procedure that is calling this procedure.

    This line...

    For j = 0 To nExchange

    Should be...

    For j = 0 To nExchange - 1

    The following could cause an error if the value of 'i' falls outside the range of Combo5 or Combo7...

    Combo7.List(i) = Combo5.List(i)

    Again, get rid of any error routines and the problem may reveal itself.

    Grex

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center