LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default array: subscript out of range

I'm playing around with code to import data from a huge delimited text file.
Since i'm learning as i go, i'm trying to take the code in pieces. Below is
what i have so far.

--------------
Dim strInText As String
Dim strArray() As String
strSourceFile = "C:\ShortTest.txt"
lngInputFile = FreeFile
Open strSourceFile For Input As lngInputFile
iCount = 0
While Not EOF(lngInputFile)
Line Input #lngInputFile, strInText
strArray = Split(strInTest, "~")
Debug.Print Trim(strArray(iCount)) ' [just seeing if the data are
being read]
iCount = iCount + 1
Wend
Close lngInputFile
--------------

I get a "subscript out of range" error on the Debug.Print line. When i move
the cursor over strInText in the Line Input # line, it shows the first line
from the text file as I would expect it to look. But when i move the cursor
over the strInText in the strArray=Split line, it says = Empty. I'm guessing
this is why i get the "subscript out of range" error.

I don't know what could be causing this, but again, i'm learning as i go.
Help!

thanks
rachael
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what does 'Subscript Out of range' mean?? Gary Excel Worksheet Functions 2 March 22nd 07 01:33 AM
Subscript Out of Range Al Excel Programming 5 September 22nd 04 07:07 PM
Redim 2D Array Subscript Out Of Range Error lopsided[_10_] Excel Programming 6 February 11th 04 08:24 AM
Subscript out of range Ed Excel Programming 1 February 5th 04 07:17 PM
Subscript Out of Range error in Array... Kevin Lyons Excel Programming 3 February 4th 04 06:17 PM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"