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,913 of 10,840   
   Steve Gerrard to Paul M. Cook   
   Re: Null values in variant array   
   24 Feb 06 20:10:57   
   
   From: mynamehere@comcast.net   
      
   "Paul M. Cook"  wrote in message   
   news:ITPLf.713$FE2.377@trnddc01...   
   >   
   > "Steve Gerrard"  wrote in message   
   > news:UJWdnVVt0dMNVWLeRVn-qQ@comcast.com...   
   >>   
   >> "Paul M. Cook"  wrote in message   
   >> news:w1NLf.92$pE4.64@trnddc04...   
   >   
   > Here is some of the code:   
   >   
   >   
      
   Try this variation, checking the length of each lines(R), and only adding to   
   the_array if there is something there. Then it redims the_array to the final   
   size.   
      
   Private Sub Command1_Click()   
   Dim whole_file As String   
   Dim lines As Variant   
   Dim the_array() As Variant   
   Dim num_rows As Long   
   Dim R As Long   
   Dim N As Long   
      
       whole_file = "1234,abcd,9876" & vbCrLf _   
             & "2334,kjkjk,0008" & vbCrLf _   
             & vbCrLf & vbCrLf   
      
       ' Break the file into lines.   
       lines = Split(whole_file, vbCrLf)   
      
       ' Dimension the array.   
       num_rows = UBound(lines)   
       ReDim the_array(num_rows)   
      
       ' Copy the data into the array.   
       N = 0   
       For R = 0 To num_rows   
         If Len(lines(R)) > 0 Then   
           the_array(N) = Split(lines(R), ",")   
           N = N + 1   
         End If   
       Next R   
      
       num_rows = N - 1   
       ReDim Preserve the_array(num_rows)   
      
       For R = 0 To num_rows   
           For N = 0 To UBound(the_array(R))   
               Debug.Print the_array(R)(N),   
           Next N   
           Debug.Print   
       Next R   
      
   End Sub   
      
   --- 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