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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where to ReDim an Array?

Status
Not open for further replies.

jbuckner

Programmer
Aug 7, 2006
1
0
0
US
I need help to figure out how to ReDim a two-dimensional array. The column size is a fixed number of elements but the number of rows will vary based on the number of records in the input file. In this example, I am reading in an account number, gathering data from the screen, then going to the next account number and continuing until the end of file. The variable procrec% is just the current line number from the input file. Your help is very much appreciated!

Open "C:\test.txt" for Input as 1
Open "C:\audi.txt" for Output as 2

procrec% = 0
Dim tArray()
ReDim tArray(procrec%,4)

GetBal:

filend% = eof(1)
If filend% = -1 then Goto FileEnd:

acctno$ = Input$(12,1)

tArray(procrec%,0) = acctno$

Sess0.Screen.Sendkeys acctno$
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime%)

tArray(procrec%,1) = Trim(Sess0.Screen.GetString(14,3,11))
tArray(procrec%,2) = Trim(Sess0.Screen.GetString(14,6,11))
tArray(procrec%,3) = Trim(Sess0.Screen.GetString(14,9,11))

Print #2, tArray(procrec%,0),";",tArray(procrec%,1),";",tArray(procrec%,2),";",tArray(procrec%,3)

procrec% = procrec% + 1

Sess0.Screen.SendKeys("<PF14>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime%)
GoTo GetBal:

FileEnd:
Print #2, "Input Records: "; procrec%
Close 1, 2
 
No this isn't a real solution to your problem, but i find it easier, first to count the rows and define my varible and then run it, rather than using ReDim in the middle of the program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top