You are here:

Qbasic, Quickbasic/Correct syntax for drawing a line between points A and B.


I want to draw a straight line between two points identified in my program as A and B. Point A is located by its coordinates x,y , and point B is located by its own coordinates x,y, (different from point A). My question is, what is the correct way to write the LINE command when each of the points A and B has two coordinates of its own?  How would they be represented in the LINE syntax?
Thank you very much in advance of your answer, as this is driving me nuts!

Hi Victor,

You line statement should look like this:

DIM col% = 15 ' 15 is white in 16-colour modes.
LINE (Ax, Ay)-(Bx, By), col%

Before you draw lines, you have to set a SCREEN mode, which tells QBasic to use a graphics mode, and selects different colours/resolutions.  Keep in mind that this was meant to support DOS-like operating systems, so you won't be getting high resolution and all the colours you may be used to seeing in your operating system.

Here is the SCREEN statement documentation for more information on resolution and available colours.

Also, if this is too limiting, you may want to look into libraries that are able to access higher resolution and more colour modes; take a look at Future.Library and UGL.

- Alex

Qbasic, Quickbasic

All Answers

Ask Experts


Alex Barry


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.


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 forums, but I appear on occasion on's forums as well.

Highschool - 2007

©2017 All rights reserved.