Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 2nd, 2005, 09:11 PM
solinent solinent is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 70 solinent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 25 sec
Reputation Power: 4
Ordering numbers in arrays.

Can someone tell me how to order a set of numbers. Here's how things are set up:

I want the variable "Player(0, 0)" to contain (in an array) the order of a few numbers. (Player(0, 0) would be the highest, Player(0, 1) would be next, all the way to 10) (I would also do this for Player(1, 1) and so on until 20 actually, and I'm prepared for loading times, but I want it to be as fast as possible... (progressbar is included))

Lets say there were two Players. I have a variable for each, which contains the number to order (lets say PlayerLvl(0, 0) is the variable, and PlayerLvl(1, 0) is the second). Lets say PlayerLvl(0, 1) is the higher one. This how is what Player would contain:

Player(0, 0) = 1 'PlayerLvl(1, 0)
Player(0, 1) = 0 'PlayerLvl(0, 0)

I need a function to assign "Player", in the order greatest to least, the first dimension of PlayerLvl.

I hope you understand. All of those 0's and 1's sure do look like binary...

Thanks!


P.S.

(If that doesn't make sense, providing an efficient way to order numbers (I need to order numbers an average of 21 x 50 times while doing this))

I hope to make this loading only around 10 - 20 seconds for 50 people if it's possible (or less would be great actually, I'm not sure how long it'd take!)

Reply With Quote
  #2  
Old December 3rd, 2005, 05:32 PM
solinent solinent is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 70 solinent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 25 sec
Reputation Power: 4
ok, I didn't get help fast enough, so I just stored all records into an Access database, and now I can sort

Reply With Quote
  #3  
Old December 4th, 2005, 04:29 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is online now
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,723 Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 5 h 27 m 40 sec
Reputation Power: 1914
you can also use something known as "disconnected recordset" and save
yourself the need for database. here is full sample code in vbscript, it can
be converted easily to VB:
Code:
<% Option Explicit %>
<% 
   Public arr, x
   arr=Array(12,87,44,56,123,543,32,55,95,87)
   
   Call PrintArray(arr)
   Call rsSort(arr)
   Call PrintArray(arr)
   
   Sub PrintArray(myArr)
      Response.Write("<BR><U>Start of array:</U><BR>")
      For x=LBound(myArr) To UBound(myArr)
          Response.Write("<B>"&x&". "&myArr(x)&"</B><BR>")
      Next
      Response.Write("<U>End of array</U><BR><BR>")
   End Sub
   
   Sub rsSort(ByRef myArr)
      Dim rs
      Set rs=Server.CreateObject("ADODB.Recordset")
      Const adVarChar = 200
      Const adInteger = 3
      Const adDate = 7
      
      '''rs.Fields.Append "date", adDate
      '''rs.Fields.Append "type", adVarChar, 255
      
      rs.Fields.Append "Key", adInteger
      rs.Open
      
      For x=0 To UBound(myArr)
          rs.AddNew : rs.Fields("Key").Value = myArr(x)
      Next
      
      rs.Sort="Key DESC"
      
      rs.MoveFirst
      
      x=0
      Do While Not rs.EOF
         myArr(x)=rs("Key")
         x=x+1
         rs.MoveNext
      Loop
      
      rs.Close
      Set rs=Nothing
   End Sub
%> 

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Ordering numbers in 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 1 hosted by Hostway
Stay green...Green IT