• Welcome to Valhalla Legends Archive.
 

Cdkey list problem

Started by oldskooldrew, October 04, 2004, 09:17 PM

Previous topic - Next topic

oldskooldrew

I'm wanting this sub to load cdkeys to a listbox, but instead of loading them all, i want it to load product specific keys when the combo box for changing product changes, or when the form loads. But im not getting it to load the right ones when it does, or loads nothing at all, im stumped and am not sure whats wrong with my code, other than the fact that i wrote it (lol joke).


Private Sub LoadCDKeys()
On Error Resume Next
lstCDKeys.Clear
    If UBound(CDKeys()) > 0 Then
        For i = 1 To UBound(CDKeys())
            If cboProduct.Text = "VD2D" Then
                If LCase(Mid(CDKeys(i), 1, 6)) = "[D2DV]" Then
                    lstCDKeys.AddItem Mid(UCase(CDKeys(i)), 7, Len(CDKeys(i)))
                Else
               
                End If
            ElseIf cboProduct.Text = "PXES" Or "RATS" Then
                If LCase(Mid(CDKeys(i), 1, 6)) = "[STAR]" Then
                    lstCDKeys.AddItem Mid(UCase(CDKeys(i)), 7, Len(CDKeys(i)))
                Else
               
                End If
            Else
   
            End If
        Next i
    Else
    End If
End Sub

drivehappy


Private Sub LoadCDKeys()
On Error Resume Next
lstCDKeys.Clear
    ' You don't need to check for this, if it's zero the for loop will skip
    'If UBound(CDKeys()) > 0 Then   
        For i = 0 To UBound(CDKeys()) - 1
            If cboProduct.Text = "VD2D" Then
                If LCase(Mid(CDKeys(i), 1, 6)) = "[D2DV]" Then
                    lstCDKeys.AddItem Mid(UCase(CDKeys(i)), 7, Len(CDKeys(i)) - 6)
                Else
               
                End If
            ElseIf cboProduct.Text = "PXES" Or cboProduct.Text = "RATS" Then
                If LCase(Mid(CDKeys(i), 1, 6)) = "[STAR]" Then
                    lstCDKeys.AddItem Mid(UCase(CDKeys(i)), 7, Len(CDKeys(i)) - 6)
                Else
               
                End If
            Else
   
            End If
        Next i
    'Else
    'End If
End Sub


See if that'll work. I changed your Else If statement, when using Or you need to repeat the condition. I also changed UBound() to UBound() -1 because you checked your CDKeys()  starting at index 1.

oldskooldrew

thanks, actually yours did not work, even though i took those out, i was matching it using LCase() and it was suppose to be UCase() thanks alot tho