|
|
|
|
|
Dicas
|
|
Visual Basic (Declarações/Variáveis)
|
|
|
Título da Dica: Checando se há duplicidades em um array
|
|
|
|
Postada em 4/10/2003 por ^HEAVY-METAL^
Private Sub Command1_Click() Dim i() As Integer ReDim i(4) As Integer i(0) = 1 i(1) = 2 i(2) = 3 i(3) = 3 i(4) = 5 MsgBox AnyDup(i) End Sub
Public Function AnyDup(NumList As Variant) As Boolean Dim a As Long, b As Long 'Start the first Loop For a = LBound(NumList) To UBound(NumList) 'Start the second Loop (thanks For the s ' uggestions everyone)
For b = a + 1 To UBound(NumList) 'Check If the values are the same 'If they're equal, Then we found a dupli ' cate 'tell the user And End the Function If NumList(a) = NumList(b) Then AnyDup = True: Exit Function Next Next End Function
T+,
|
|
|
|
|