NileshSutar Posted September 24, 2013 Share Posted September 24, 2013 Hi guys, i want to compare two "2D" arrays such that it should return 0 if no element is common and 1 if one or more elements are common.How can i do that.??? Link to comment Share on other sites More sharing options...
FireFox Posted September 24, 2013 Share Posted September 24, 2013 Hi, Nested For. Think in your head how you would do it and then translate it, quite easy. Br, FireFox. Link to comment Share on other sites More sharing options...
NileshSutar Posted September 24, 2013 Author Share Posted September 24, 2013 i have done it> but the arrays come from different function.How can i import them in my compare function Link to comment Share on other sites More sharing options...
FireFox Posted September 24, 2013 Share Posted September 24, 2013 Post your code, so we can see what you're talking about Br, FireFox. Link to comment Share on other sites More sharing options...
water Posted September 24, 2013 Share Posted September 24, 2013 Define both arrays by using Global to make them available for every function. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Gianni Posted September 24, 2013 Share Posted September 24, 2013 (edited) Assuming both arrays has the same number of elements, something like this should work Func Compare2D(ByRef $Array1, ByRef $Array2) Local $Check = 0 For $x = 0 To UBound($Array1, 1) -1 For $y = 0 To UBound($Array1, 2) -1 $Check += ($Array1[$x][$y] = $Array2[$x][$y]) Next Next $Check = $Check > 0 Return $Check EndFunc ;==>Compare2D (not tested) bye edit added -1 to ubound in listing Edited September 24, 2013 by PincoPanco Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
NileshSutar Posted September 24, 2013 Author Share Posted September 24, 2013 Define both arrays by using Global to make them available for every function. Worked thanks Link to comment Share on other sites More sharing options...
AZJIO Posted September 24, 2013 Share Posted September 24, 2013 First check that the dimensions of the array are the same. Make "ExitLoop" out of the loop if the going does not match. I don't think that should be checked until the end, if the first cell is not the same. My other projects or all Link to comment Share on other sites More sharing options...
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