|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
QBASIC and ARRAYS
in my qbasic program, i keep getting subscript out of range, but am sure i made enough, my program works for the first 2 arrays, but once i add the if then after the ==== it tells me subscript out of range.
this is what is going on >>> DIM prices(1 TO 7), lestype$(1 TO 7) FOR n = 1 TO 7 READ prices(n), lestype$(n) NEXT n DIM location.total.owed(1 TO 6) DIM location.names$(1 TO 6) DIM location.customers(1 TO 6) DIM location.lessons(1 TO 6) DIM city$(1 TO 6) FOR n = 1 TO 6 location.total.owed(n) = 0 location.customers(n) = 0 location.lessons(n) = 0 NEXT n city$(1) = "Dearborn" city$(2) = "Canton" city$(3) = "Novi" city$(4) = "Southfield" city$(5) = "Detroit" city$(6) = "Other" location.names$(1) = "DEA" location.names$(2) = "CAN" location.names$(3) = "NOV" location.names$(4) = "SOU" location.names$(5) = "DET" ================================= locat$ = UCASE$(locat$) IF locat$ = location.names$(n) THEN location.total.owed(n) = location.total.owed(n) + 1 location.customers(n) = location.customers(n) + 1 location.lessons(n) = location.lessons(n) + 1 ELSE location.total.owed(6) = location.total.owed(6) + 1 location.customers(6) = location.customers(6) + 1 location.lessons(6) = location.lessons(6) + 1 END IF PRINT USING N6$; city$(n); location.customers(n); location.lessons(n); location.total.owed(n) |
|
#2
|
|||
|
|||
|
What's the locat$ variable define in your code??
|
|
#3
|
|||
|
|||
|
u read locat$ from the data
|
|
#4
|
|||
|
|||
|
the locat$ variable is a parameter which u input??
|
|
#5
|
|||
|
|||
|
its in the DATA line after the program, its a program for school, so the data is typed after the program. i dono what parameter means
|
|
#6
|
|||
|
|||
|
it is valid its working like it is supposed to, the problem is in the arrays
|
|
#7
|
|||
|
|||
|
Do u have a mistake in your code,because i couldn't find UCASE$ in QB!
|
|
#8
|
|||
|
|||
|
UCASE$ like LCASE$ is one of those codes already in the program, it makes something all caps or all lower case.
the problem was in my FOR NEXT i dont understand those, the teacher showed me what i did wrong, but i didn't understand. so if u know a easy to follow tutorial for those with short attention span on FOR NEXT and ARRAYS ill be thankful. |
|
#9
|
|||
|
|||
|
U can find some tutorial on network for learn QB syntax:http://www.tutorgig.com/showurls.jsp?group=798&index=1
|
|
#10
|
|||
|
|||
|
thanks man
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > QBASIC and ARRAYS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|