Qbasicnews.com

Full Version: Please, patch my command desperation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please tell me how can you make a computer create a new variable (I need it in combination with IF)? Thank you!
In QBasic?

If so, you don't have to predefine it, like in C. You can just start using it.

You can make an IF...THEN statement to give it a value.... If that's what you mean.

Code:
If MyOption% = 1 Then NewVar% = 50
Sorry, but now that I've thought, I need a string variable and I'm total beginner. How do you set up a string variable and how do you add more variables and text to it? I can't understand that part in the QBASIC help.
You can use a "user defined data type"...

For instance, if I wanted to have a string variable and an integer variable with the same prefix...

Code:
TYPE MyDataType
MyStr as String * 17
MyInt as Integer
End Type

Dim MyData as MyDataType

MyData.MyStr = "This is a string!"
Mydata.MyInt=13

Print MyData.MyStr
Print MyData.MyInt

This could help a little... also study the QB help file. Wink
do u mean this?

s$ = "abc" 's$ is abc
s$ = str$ + "def" 's$ is now abcdef
Thank you!
Thank you!