You are here:

Qbasic, Quickbasic/What is text1.text in qbasic

Advertisement


Question
I'm taking classes for a 9th grade student from a different school. She's got the following code for accepting user entry from her teacher at school. But i'm not aware of anything of the sort in qbasic. Pl. help !

a=val(text1.text)
if a mod 2=0 then
print "The number entered is an even number"
else
print "The number entered is an odd number"
endif


why are they using text1.text and not INPUT to acept a number from the user ?? More importantly, is text1.text allowed in Qbasic ???
Please Help !

Answer
Hi, Smitha,
text1.text is definately a variable, but just how it is written, it looks like it is more likely from Visual Basic, opposed to QBasic.

Either way, you could change that to this:

DIM text AS STRING
DIM a AS INTEGER
INPUT "Number: ", text
a = VAL( text )
IF ( a MOD 2 ) = 0 THEN
 PRINT "The number entered is an even number"
ELSE
 PRINT "The number entered is an odd number"
END IF

I hope that answers your question.  Again, you may want to look into the class to see if it is teaching QBasic or Visual BASIC

Take care,
-Alex

Qbasic, Quickbasic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Alex Barry

Expertise

I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, QB64, c/c++, python, lua, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience

I have been programming in *Basic dialects since 2000, as mentioned in my expertise. After a year of QBasic, I learned C and C++, and dabbled a little in ASM (I don't program in ASM - I literally just played around to see how things work). When QB64 and FreeBASIC were released, I played with those languages. At the time, FreeBASIC offered more functionality and I sided with that language for a while. During that time, while I was learning new languages, that I would see what scripting languages are available, where I took up python and lua. I started to notice a staleness to QB64's development (which I kept tabs on from time to time), and am now trying to be active in it's community and maybe in it's development in the future. Currently, I am only active on the QB64.net forums, but I appear on occasion on FreeBASIC.net's forums as well.

Education/Credentials
Highschool - 2007

©2012 About.com, a part of The New York Times Company. All rights reserved.