Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Total newbie to programming & QBasic...stuck on a VERY simple program. Basically, I need to transfer data from a Notepad file into the program (as an array). I need to transfer about 200 numbers, but every time I try to input more than 10, I get an error message...Please help!

It would help if you posted your program.
Here is a program that reads 200 DOUBLES from a text file. It then prints out the numbers to the screen.
CONST MAX = 200
DIM n(MAX) AS DOUBLE
DIM i AS INTEGER
OPEN "f:\my.dat" FOR INPUT ACCESS READ AS #1
FOR i = 1 TO MAX
INPUT #1, n(i)
NEXT i
CLOSE #1
FOR i = 1 TO MAX
PRINT i, n(i)
NEXT i

Thanks, egkenny...I'll try that. But just in case, here's what I tried to do first...
OPEN "datafile.txt" FOR INPUT AS #1
FOR n=1 to 200
INPUT #1, a(n)
PRINT a(n)
NEXT n
CLOSE #1
END

BTW, there should not be a problem with the size of your array. I tested QBASIC to see what the limits are. The limits depend upon the the data type the number of dimensions. In any case the limits for a one dimensional array of any number type is much larger than 200. You did not say what version of QBASIC you were using. I did my tests with the QBASIC from DOS 6.22 that came with Windows 95. I ran this QBASIC under Windows XP.

Oops...sorry, forgot to include that info. I'm using QBasic 4.5 on Windows 95. But I've been having other problems with the program, supposedly because of not having enough conventional memory (which just doesn't make sense!). Anyways, I tried your code, and it worked beautifully. Thanks a lot for all your help!!!

It sounds like you have QuickBASIC 4.5 which is based on QBasic. I tested the code in Qbasic 1.1 which came with DOS in Windows 95. QuickBASIC was a seperate program sold by Microsoft. I also have QuickBASIC 4.5. QuickBASIC has many improvements over QBasic. The major one is that you can compile your program and produce an executable ".exe" file.

![]() |
Html Alignment
|
C# and Excel
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |