Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about saving string values to MD $ arrays

Status
Not open for further replies.
Nov 20, 2013
1
US
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.
 
Can you include the all relevant code? I don't want to assume the values of "save" and how the wally$ array is defined.

In order to accept an alphanumeric value from INPUT, the "capture" variable must be a string. You were right to use hold$

Code:
INPUT "Enter new item description"; hold$
wally$(2, save) = hold$

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top