Fran Posted September 10, 2010 Posted September 10, 2010 (edited) Wonder if someone can help me with this please... my brain is in Friday-mode I have an array that I want to check for duplicate values and then warn the user. Below is an example extract from my code: $sArray = StringSplit("123,456,789,321,654,789,987", ",") $cntSamples = $sArray[0] ;if <there is a duplicated value in the array> then MsgBox(4096, "Error", "There are duplicate values in the array.") ;and echo the value EDIT: I'm sorry for posting on this forum.. I didn't realise when I made the post. And now I don't know how to delete this and post on the general forum. Edited September 10, 2010 by Fran
water Posted September 10, 2010 Posted September 10, 2010 I would use something like this: #include <array.au3> $aArray = StringSplit("123,456,789,321,654,789,987", ",") _ArrayDisplay($aArray) ; Only tells if there are differences $aNewArray = _ArrayUnique($aArray, 1, 1) _ArrayDisplay($aNewArray) If $aArray[0] <> $aNewArray[0] Then MsgBox(4096, "Error", "There are duplicate values in the array.") ; Shows the duplicate values _ArraySort($aArray, 0, 1) _ArrayDisplay($aArray) For $index = 1 To $aArray[0]-1 If $aArray[$index] = $aArray[$index+1] Then MsgBox(4096, "Error", "Value '" & $aArray[$index] & "' is a duplicate value in the array") Next My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now