QBasic Tutorial 15 - Arrays - QB64
Вставка
- Опубліковано 18 гру 2024
- www.SchoolFreew...
Arrays hold lists of variables of the same data type. When there are large lists of variables and data, it is easier to contain the data in an array than have large amounts of separate variables to hold the data. Think of an array as a placeholder for piece of data.
The syntax of the array is:
DIM array_name(number_of_items) AS datatype
The name of the array, FNames is marked as Invalid Identifier. I am using QB45 in Windows 8 free version with 4gb Ram and without DosBox installed. Pls help
I am not sure what the problem is. The code is available for download at SchoolFreeware.com. Check that code with what you have, for typos.
@@SchoolFreeware It simply doesnt work and invalid identifier is shown. I have rechecked the code.
Hello, I have installed QuickBasic 4.5 in DosBox and tried this out. FNames seems to be a reserved word in 4.5. This is not the case with QBasic 1.1 and QB64. Change FNames to something else like FirstNames.
DIM FirstNames(5) AS STRING
DIM x AS INTEGER
CLS
FirstNames(1) = "Joe"
FirstNames(2) = "Jim"
FirstNames(3) = "Jill"
FirstNames(4) = "Joan"
FirstNames(5) = "Jan"
FOR x = 1 TO 5
PRINT FirstNames(x)
NEXT x
Yes the amount of the items you can have in your array depends on the data type and the amount of free memory (ram).
Thanks I was wondering how arrays worked since I was confused how the variables worked and the dim
Hah... year old comment. Ah well, still a problem for me. If I last recall, I could only have 10 items in an array. Then it'd start giving me errors and such. Do you know how to increase the amount an array can hold, if it's possible?
does any one know how to setup boundaries qb64? im trying to setup a maze game. and i what i want it to is where if the character hits the line it sends you back to the start of the game does any know how to do that?
I'm a computer nerd and i have watched this vis 10 times .
unlike other tutorials i forget all of these in a week...........
*Sadness*
_cries_
Is there a limit to how many items you can have?
That's a really old comment. It depends on the version you've got and is it 64 bit? The newer 64 bit version can handle up to 9 quintillion elements. While the 32 bit version can handle around 2 billion. There's also pretty much the difference between 64 bit and 32 bit explained lol
Isn't there n(0) in array n(5) ? That make 6 isn't it?
@SchoolFreeware why did we need to zeroize the counter and the guess?
The "Sum" variable needs a blank canvas so that the Num(1) can be in the sum after one loop
Ok sir Thankx👍
Thanks that was a big help for my exams
thank you sir. this helped me a lot
Sir I am in grade 7. In school We do not use DIM but use REM in the beginning. Arrays do not work without DIM. I do not understand. Please help me out with this.
REM is used for commenting ffs
Divya Rajparia ohh thanks
I am in Grade 8, but I haven't read Arrays in QBasic in last year, and also DIM is not compulsary, it declares what variable is what (for eg. X is string), Rem is used for giving comments, they are both very different topics
DIM is better imho
oh thankss.
Good stuff
what if user must enter a nubmer of arrays?
DIM a(10) 'For example
CLS
FOR i = 1 to 10
INPUT "Enter a number and press enter"; a(i)
NEXT i
FOR i = 1 to 10
PRINT a(i)
NEXT i
END
'DONE!!
HEY! Can anybody help me with using read-data statement with arrays?
Tutorial 18 has read data with a 2D array.
Nice and concise
Nice one
Geez I feel bad for the keyboard
This is nothing watch tutorial 50 and you'll see
Thanks alot man
execpt on the qb64 website
This is not working
the internet won't tell me what dim means!
Dim means declaring a type of variable
for eg:
If I want to declare name as string then I have to do:
DIM name AS STRING
Otherwise Qbasic will read it as a numeric variable, I hope this helps
it means dimension, notable for specifying arrays and their rank. Its an odd keyword for sure.
It means dimensions
damn anyone in 2020 here
no
@@elliottsampson1454 imma edit and put 2021 now lel
comment
Doesn't work. The new version of qbasic doesnt need quotations and i get a syntax error. Why do schools still use this crap? The dinosaur professors need to get with python.
David M Honestly, which grade are you in? The last time I studied QB64 was in Highschool. It's the most basic programming language so, it's compulsory to be taught. You cannot start running if you don't know how to walk. Many C languages like C Sharp are mostly similar. Python isn't that much of a difficult language either.
I am in 6th class but my teacher tells in the old version
second
Thanks that was a big help for my exams
Thanks that was a big help for my exams