home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,155 of 10,840   
   James L Hill to All   
   Re: Sorting help please   
   21 Jan 05 03:53:46   
   
   From: james.hill83@verizon.net   
      
   I would approach this problem with a two fold solution. First convert the   
   months to numeric for ease of sorting. I would use a Case Statment for that.   
   Then store the data in a database which you can then retrieve in any order   
   you like.   
      
   Dim dblIndex As Double   
   Dim strMonth As String   
   Dim intYear As Integer   
   Dim intMonth As Integer   
   Dim filename As String   
      
      
   Open filename For Input As #1   
   Input #1, dblIndex, strMonth, intYear   
      
   'Convert Month to numeric   
   Select Case strMonth   
   Case "Jan", "January", UCase("January")   
       intMonth = 1   
      
   Case "Feb", "Febuary", UCase("Febuary")   
       intMonth = 2   
      
   Case "Mar", "March", UCase("March")   
       intMonth = 3   
      
   Case "Apr", "April", UCase("April")   
       intMonth = 4   
   ...   
   End Select   
      
   Add record to database:   
   Dim RS As Recordset   
   ...   
   RS.Fields("Index") = dblIndex   
   RS.Fields("Month") = intMonth   
   RS.Fields("Year") = intYear   
   RS.Update   
      
   Retrieve record in asc order:   
   RS.open "Select * From database Order By Year,Month,Index", conn,   
   adOpenDynamic   
      
      
      
   "Terry"  wrote in message   
   news:1106222107.ead5bf9368f49d6833298cede41b531c@teranews...   
   > I have a text file with an unknown number of entries in it.  The data   
   > in the text file is in this format:   
   >   
   > 22.9,"June",2004   
   > 6.7,"July",2003   
   > 18.3,"June",2004   
   >   
   >   
   > dblIndex, strMonth, intYear   
   >   
   > How do I sort these by date (from newest to oldest) and if the records   
   > have the same date, from lowest dblIndex to highest?   
   >   
   > Any help with this problem would be greatly appreciated.   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca