🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #712

Re: confronto tra numeri

#712
From: Max
Date: Wed, 05 Oct 2005 22:31
51 lines
2207 bytes
"El Gioppinho" <daropp@ELIMINABINLADENtin.it> ha scritto nel messaggio 
news:CccVe.42399$O6.2428029@news3.tin.it...
> Esiste una funzione in vb che permetta di controllare facilmente se una
> sequenza di numeri interi sono tutti diversi tra loro ?
>

Non mi pare che esista...

> Se non esiste (e per quanto abbia controllato nell'help, non mi pare di
> averla vista) avete qualche suggerimento su come potrei realizzarla ?
>
> Grazie.
>
>

Io metterei la sequenza in un array...
prova con un form dove inserisci una button "Command1"
poi prova a cambiare la sequenza di numeri nell'array aa
nell'esempio hai i due casi...

Private Sub Command1_Click()
Dim aa
aa = Array(10, 12, 33, 44, 15, 11)
If CheckNumber(aa) Then
  MsgBox ("Tutti diversi...")
Else
  MsgBox ("Opsss... Duplicati presenti")
End If
'
aa = Array(10, 12, 33, 44, 15, 11, 12)
If CheckNumber(aa) Then
  MsgBox ("Tutti diversi...")
Else
  MsgBox ("Opsss... Duplicati presenti")
End If
End Sub

Function CheckNumber(aMyNumber)
Dim lOk As Boolean
lOk = True
For cnt1 = 0 To UBound(aMyNumber) - 1
    For cnt2 = cnt1 + 1 To UBound(aMyNumber)
        If aMyNumber(cnt1) = aMyNumber(cnt2) Then
            lOk = False
            Exit For
        End If
   Next
Next
CheckNumber = lOk
End Function
Technical Details
Message-ID: <43445447$0$8479$5fc30a8@news.tiscali.it>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!draco.tiscalinet.it!news-f1.tiscali.it!not-for-mail
References: <CccVe.42399$O6.2428029@news3.tin.it>

Show Full Headers
Complete Article Headers
X-Google-Thread: f94ee,dc11fb8d7902131d
X-Google-Attributes: gidf94ee,public
X-Google-Language: ITALIAN,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!draco.tiscalinet.it!news-f1.tiscali.it!not-for-mail
From: "Max" <max@fratellimenegazzo.it>
Newsgroups: free.it.visual-basic
References: <CccVe.42399$O6.2428029@news3.tin.it>
Subject: Re: confronto tra numeri 
Date: Thu, 6 Oct 2005 00:31:33 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
Lines: 54
Message-ID: <43445447$0$8479$5fc30a8@news.tiscali.it>
Organization: Tiscali SpA
NNTP-Posting-Host: 84.222.82.145
X-Trace: 1128551495 news.tiscali.it 8479 84.222.82.145:3825
X-Complaints-To: abuse@tiscali.it