Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReDim String count from .txt file

Status
Not open for further replies.

Bass71

MIS
Jun 21, 2001
79
0
0
Hi:

I am using the Input function to enter strings of data from a comma delimited text file into TSO mainframe. The number of strings in the text file will vary from run to run (but usually not more than 75). I have setup the code as follows:

Dim strAC(75) as String
Dim filenum as Integer
Input #filenum, strAC(1), strAC(2)...strAC(75)

Using For Next statement, the code enters the string in applicable spaces.

If for example, I have 5 strings of actual data and 70 strings of ,"", then I want the code to be able to count the non-empty strings and ReDim the strAC(5), automatically. How is this accomplished?

Thanks for your help.............Rich O
 
You must declare the array as dynamic to start with, then reDim the array once you know how many data elements you'll have.

Dim strAC() as String
ReDim strAC(5) as String

You can then ReDim the array as often as necessary in code.

calculus
 
To keep the values already in a dynamic array, use:
Code:
ReDim Preserve strAC(5) As String

Otherwise it will be reset each time... usually.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top