×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Where to ReDim an Array?

Where to ReDim an Array?

Where to ReDim an Array?

(OP)
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

RE: Where to ReDim an Array?

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close