Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: oldskooldrew on October 04, 2004, 09:17 PM

Title: Cdkey list problem
Post by: oldskooldrew on October 04, 2004, 09:17 PM
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
Title: Re: Cdkey list problem
Post by: drivehappy on October 04, 2004, 11:53 PM

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.
Title: Re: Cdkey list problem
Post by: oldskooldrew on October 05, 2004, 12:11 AM
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