.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 6th, 2004, 09:16 AM
edp1959 edp1959 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 edp1959 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow need help with arrays

I'm new with Visual Basic but i believe this should be simple,
i just can't come up with a VB code that will work.
I have two array lists:
itemArr: 1,2,3,4,5,6,7,8,9,21,32
IndexArr: 2,3,4,5,6,7,8,9,10,22,33

What would the VB code look like to compare these two arrays
and return the first number to a textbox that is in indexArr
but not in itemArr?

Last edited by edp1959 : April 6th, 2004 at 09:19 AM. Reason: lists were not clear

Reply With Quote
  #2  
Old April 7th, 2004, 04:43 PM
wink wink is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 wink User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
return first value that in indexArr but not in itemAr?

Here is the code, I haven't try it. but it should work

Dim itemArr() as Integer = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 21, 32 }
Dim IndexArr() as Integer = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 33 }
Dim flag as boolean = false
Dim i, j as integer

For i = 0 to UBound(itemArr)
For j = 0 to UBound(IndexArr)
if (itemArr(i) == IndexArr(j)) then
flag = true
exit for
end if
Next
if (flag == false)
return itemArr(i)
end if
Next

wink,

Less than $1 / month Web hosting
URL

Reply With Quote
  #3  
Old April 15th, 2004, 11:00 AM
pmuk pmuk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: USA
Posts: 21 pmuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This works exactly what you want......

Dim itemArray() AsInteger = {1, 2, 3, 4, 5, 6, 7, 8, 9, 21, 32}
Dim IndexArray() AsInteger = {2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 33}

Dim fgEqual AsBoolean = False

Dim i, j AsInteger

For i = 0 To UBound(IndexArray)

For j = 0 To UBound(itemArray)

If (itemArray(j) = IndexArray(i)) Then

fgEqual = True

ExitFor

EndIf

Next

If (fgEqual = False) Then

Textbox1.Text = (IndexArray(i).ToString)

ExitFor

EndIf

fgEqual = False

Next


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > need help with arrays


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT