Need help with an array!

  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

I get a type mismatch on the column0 line every time.
Code: [ Select ]
arrIndex = 0
while not rs.EOF
                                                
    arr(0, arrIndex) = rs("column0").value
    arr(1, arrIndex) = rs("column1").value    
    arr(2, arrIndex) = rs("column2").value    
    arr(3, arrIndex) = rs("column3").value    
    arr(4, arrIndex) = rs("column4").value
                        
    arrIndex = arrIndex+1
    rs.movenext                        
wend
  1. arrIndex = 0
  2. while not rs.EOF
  3.                                                 
  4.     arr(0, arrIndex) = rs("column0").value
  5.     arr(1, arrIndex) = rs("column1").value    
  6.     arr(2, arrIndex) = rs("column2").value    
  7.     arr(3, arrIndex) = rs("column3").value    
  8.     arr(4, arrIndex) = rs("column4").value
  9.                         
  10.     arrIndex = arrIndex+1
  11.     rs.movenext                        
  12. wend


Any suggestions?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

What a pain in the array...after way too long I've finally solved it...

the issue was with dimensioning the array. here's the fix:

Code: [ Select ]
optionStr = ""
redim preserve arr(3,ubound(arr,2)+1)                    
while not rs.EOF            
    arr(0, ubound(arr,2)) = rs("column0").value
    arr(1, ubound(arr,2)) = rs("column1").value    
    arr(2, ubound(arr,2)) = rs("column2").value
    arr(3, ubound(arr,2)) = rs("column3").value
    rsOptions.movenext                        
wend
set rs = nothing
  1. optionStr = ""
  2. redim preserve arr(3,ubound(arr,2)+1)                    
  3. while not rs.EOF            
  4.     arr(0, ubound(arr,2)) = rs("column0").value
  5.     arr(1, ubound(arr,2)) = rs("column1").value    
  6.     arr(2, ubound(arr,2)) = rs("column2").value
  7.     arr(3, ubound(arr,2)) = rs("column3").value
  8.     rsOptions.movenext                        
  9. wend
  10. set rs = nothing

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 82 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.