Questions and Their Answers, Respectively
Go Home What's new? The File Library The Newsroom Links to Other Pages Q&A Tutorials
[ home | what's new | files | tutorials | q&a | news | links ]

There is a new part of the page now in beta testing - a page where you can post your own questions and get answers from other people via e-mail or other posts. It's still in the very rough stages, but give it a shot. Click here to try it.

I really want to see one of those ad banners one more time!

Here you go!
Internet Link Exchange
Member of the Internet Link Exchange

Quick Reference for QB Q&A


How can I donate to help keep The QBasic Page alive?

Click here for more information on donations.


I have Windows 95 and I can't find QBasic!!

Thanks to Justin Crowell, now you can. QBasic is found on the Win95 CD-ROM in the 'OTHER\OLDMSDOS' directory. All you have to do is copy QBASIC.EXE and QBASIC.HLP to your hard drive from this directory, and you're set! Thanks, Justin!


I WANT QBASIC 4.5!!

Okay, if you can't guess, I'm getting sick of this question and the above one :( but this should give you a quick answer. QBasic 4.5 is not being made by Microsoft anymore and you can't get a copy off the Internet without breaking several international laws. I know of no places that sell it.. sorry!


From: IN:Rodger_Petersen@msn.com

How do I convert GW-BASIC programs to QBasic?

The first thing to do is to make sure the file is saved in ASCII mode - if you can look at it in a text editor, then skip the next part. If not, then LOAD the program in GW-BASIC and save it like this:

SAVE "PROGRAM",A

This should save it in ASCII mode.

Try loading it and running it in QBasic. If this doesn't work, the next thing to do is to run REMLINE (a program that came with DOS 5's QBasic, but I'm not sure it does anymore), and try running it. If that doesn't work, you'll have to live with GW-BASIC, since there is no real way to load the programs any better in QBasic since it is a compiler. However, if you have QBasic 1.0 (the one that comes with DOS) it might work. If not, you'll have to retype the program.


From: lpalmer@hunterlink.net.au

How do I handle dates in QBasic?

What you can do to handle dates is isolate the different variables in the date - i.e. the month number and day number by using this: (this is from memory, so try it first and get back to me)
'--code snippet begin--
DT$ = DATE$
DO WHILE STRING$(1, DT$) <> "-"
month$ = month$ + STRING$(1, DT$)
DT$ = MID$(DT$, 2)
LOOP
month = VAL(month$)
DO WHILE STRING$(1, DT$) <> "-"
day$ = day$ + STRING$(1, DT$)
DT$ = MID$(DT$, 2)
LOOP
day = VAL(day$)

TotalDays = ((month * 30) + day)
'--code snippet end--
This is by far not the best way to do this, mostly because of the slowness of the loops. Another problem you may encounter is that there are not lways 30 days in each month - you might have to do a SELECT CASE for each month to determine the TotalDays. But that all depends on how accurate your reading needs to be.


How do I exit QBasic with errorlevels?

Here is a letter from Doug Lytle of Coldwater, MI, explaining this.
Hello.

I found out how to exit a Quickbasic program with an errorlevel! The
following needs to be added to your program or to a .DEC file:

---------------
DECLARE SUB Bye CDECL ALIAS "_exit" (BYVAL Value%)

Bye Value%

---------------

When testing this code within the QB environment, you'll need to startup with
the /l bcom45

Whatever you have set for Value% will be the errorlevel on exit and instead of
using the command END to end the program, use Bye instead. The keyword Bye is
selectable. It could be anything you wanted.

Just a snippet of code:

---------------------
input "Please enter an errorlevel"; Value%

If Value% = 40 then Bye Value%
---------------------


This would exit with an errorlevel 40 if 40 was entered.

I have also found(Not done much with errorlevels) that you have to have the
hightest errorlevel first, in a .BAT file, for it to work properly.

Sample: (correct)

if errorlevel 40 goto import
if errorlevel 30 goto export

Sample: (incorrect)

if errorlevel 30 goto export
if errorlevel 40 goto import
If your exit level is 40, 30 will be selected no matter what.

Internet: doug.lytle@dconline.org (Doug Lytle)

What about compiling my programs into .EXE files?

I can't tell you how many times I've had to answer this question via E-mail, but I finally decided to put the answer on-line. There is a way to do this. Microsoft marketed QBasic 4.5, the compiler version, several years ago. However, they recently stopped producing it. They have not yet released it into a free market, so it would be illegal for me to send it to you. I've asked Microsoft about this several times, with no reply. However, there is a light at the end of the tunnel. A Shareware compiler that is 99% compatible with QBasic is available over the Internet. It is called ASIC, and the latest version is 5.00. I will put this on my page as soon as I can, but your best bet until that happens is to go to c|net's shareware.com address and do a search for it. Okay, now you can stop sending me e-mail asking about this! ;-)


Problem: I find that I have deep feelings for you, but I don't know how to express them because I fear rejection.

Don't worry. I love you.


What is the difference between SYSTEM and END?

The SYSTEM command DOES work in Qbasic. If you type in the SYSTEM command, it acts just like the END command when you run it from inside qbasic. However, if you go to DOS and use the Qbasic /run command to execute your program, QBasic will automatically return you to DOS when you execute this command. For example:
 EndProgram:
 INPUT End$
 IF End$ = "1" THEN SYSTEM
 
NOTE: When you use the SYSTEM command when you are in QBASIC, then it acts just like the END command. It returns you back to the code screen.

So, if you are looking for a way for someone to run your program without the program terminating in QBASIC and freaking the user out, then use the SYSTEM command which safely returns the user to the operating system (DOS or WIN) and thus preventing them from going insane! Info from Satire55@aol.com


How do I create repeating background music?

Download the demo program
PLAY.BAS for information on PLAY event trapping.


How do I use the arrow keys in a program?

Download this demo -
CURDEMO.BAS - for information on trapping cursor keys from QBasic.


How do I un-ZIP files?

Download
PKUNZIP.EXE and follow the instructions.


How can I make my programs look as if they were compiled?

Here's some information from Justin Rosenberg (jprose@uit.net):
	I would have to disagree with your answer about system and end.  I
can't get any of my compilers to work with my code.  So I have learned
to make a batch file to run my programs so I can make shortcuts to it in
a Windows enviroment.  The .bat looks as folows...

echo off
cls
echo Loading...
c:
cd\basics\qbasic
qbasic.exe /run filename.bas

	This format works great.  There is only one problem.  If a end
statement terminates a program you will end up looking at the code in
Q-basic.  Although if use the system command, it will take you back to
windows.  Note:  If you are using Windows 95, you must click on the
"close on exit" button on the properties of the batch file.  I think
this format will be useful to those who want to compile there software. 
A small six line batch file will make it look like it was already
compiled.

How do I use arrays in my programs?

What is an array?

 An array is a list of data item inmemory that all have the same name
 and whose elements are differentiated by a subscript.

 In simple terms, an array can be anything that is a group of related
 numbers such as prices, phone numbers, catalog order numbers and the
 list goes on and on.

-----------------------

Why do we need them?

 From the beginning of the computer, programmers like to "cheat".  This
 means that they try to make the computer do as much as possible, which
 makes the code for a program much shorter.

 Arrays can be huge, and what person wants to input each individual
 variable.  This is why we need to "cheat" and use arrays to our
 advantage.

-----------------------

Sample code:

this is a sample for the variable (avar)

CLS

PRINT "DEMO FOR ARRAYS"

  FOR avar=1 to 100

    INPUT "What is the product number?"; prodnum(avar):PRINT

    INPUT "What is the product desciption(name)?"; prodscr$(avar):PRINT

    INPUT "are there any more products:(Y/N)"; ans$

    ans$ = UCASE$(LEFT$(ans$,1))

    IF (ans$ <> "Y") THEN

     EXIT FOR

    END IF

  NEXT avar

PRINT "hey, you made it"

PRINT prodscr$(1); tab(20); prodnum(1)

PRINT prodscr$(2); tab(20); prodnum(2)

END

-----------------------

What is the ARRAY ELEMENT in the above code?

  avar is the array variable. This is simply a name that is given to the
  array.  The important information is held in the array number or element.
  1 to 100 signifies how many prodnum and prodscr there are. Towards the end
  of the program, we used this number to take out the 1st and 2nd inputs and
  print them on the screen.

-----------------------

What is a PARALLEL ARRAY?

  A parallel array is an array that has two or more shared informations.  The
  program uses a parallel array between prodnum and prodscr$.  For example
  prodnum(1) = 409 and prodscr$(1)= Huffy Bike.  These two correspond to each
  other.  In your product database or ordering form, the Huffy bike is ordered
  as number 409.  Do you see how they are parallel.  As a final statement, the
  parallel arrays must have the same number of elements(1 to x) and must have
  related value(depending on the users need."

-----------------------
What is a DYNAMIC ARRAY?

  A dynamic array is used for constantly changing data.  This is handled in
  a different format.  Dynamic arrays are another section.  Do not ask me
  how to use them, because I don't do anything with graphics.

-----------------------

submitted by ANTHRAX
  contact him at http://ddi.digital.net/~triplej/calcpage.htm
  or e-mail me at triplej@digital.ne


I can't load the MOUSE.ZIP file in QB 4.5!

This is a problem a lot of people seem to have. It's very simple to solve.. just load QBasic up like this from the command line: qb /l. This will fix all of your problems with programs that use the CALL ABSOLUTE command. Have fun.

Now I have no more Q&A to read!

Why not write and appear here? E-mail me by clicking
here. I'll try to honestly answer any pertinent question.


Go Home What's new? The File Library The Newsroom Links to Other Pages Q&A Tutorials
[ home | what's new | files | tutorials | q&a | news | links ]

serving [an error occurred while processing this directive] QB programmers since 14 Dec 1996 8:00pm