Question about saving string values to MD $ arrays
Question about saving string values to MD $ arrays
(OP)
Firstly I am a beginner so forgive my ignorance of some of the finer points of qbasic
I am writing a program that requires saving data to a multidimensional array
The data is read in and an input statement captures the change to the given column.
so the array is a string array and saves multiple types of data
the first input statement captures a number, and changes it correctly
however the second input statement captures a description of the item, but I am confused on what I need to change, here is my code.
1:
PRINT
INPUT "Enter new upc code"; hold
wally$(1, save) = STR$(hold)
RETURN
(WORKS)
2:
PRINT
INPUT "Enter new item description"; hold
wally$(2, save) = STR$(hold)
RETURN
(DOESN'T WORK)
I have tried to change the hold to a string value, and it allows me to use alphabetical characters for the input however I keep getting a change of 0 in the array. I am confused on how to make sure to capture the input and save it to the corresponding column.
I also tried changing STR$(hold) to STR$(hold$) but it keeps giving me a "Number required for function" error, what does this mean?
Thank you for reading this, I can supply any additional information upon request.
I am writing a program that requires saving data to a multidimensional array
The data is read in and an input statement captures the change to the given column.
so the array is a string array and saves multiple types of data
the first input statement captures a number, and changes it correctly
however the second input statement captures a description of the item, but I am confused on what I need to change, here is my code.
1:
INPUT "Enter new upc code"; hold
wally$(1, save) = STR$(hold)
RETURN
(WORKS)
2:
INPUT "Enter new item description"; hold
wally$(2, save) = STR$(hold)
RETURN
(DOESN'T WORK)
I have tried to change the hold to a string value, and it allows me to use alphabetical characters for the input however I keep getting a change of 0 in the array. I am confused on how to make sure to capture the input and save it to the corresponding column.
I also tried changing STR$(hold) to STR$(hold$) but it keeps giving me a "Number required for function" error, what does this mean?
Thank you for reading this, I can supply any additional information upon request.
RE: Question about saving string values to MD $ arrays
In order to accept an alphanumeric value from INPUT, the "capture" variable must be a string. You were right to use hold$
CODE
STR$() is a function that converts a number into a string. If the function receives a string instead of a number, you will get the error "Number required for function".
-Geates
http://ns7.webmasters.com/caspdoc/html/vbscript_la...