DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links