Use Integers where-ever possible...
DEFINT A-Z
Use look up tables instead of calculating...
Multiplication and Division are
SLOW...
For these types of calculations, try to set up a look-up table to use instead of caculating in real time...
this works good for things such as Divideing by 2,3,5... and things such as Sine, Cosine...
For the SIN & COS...
DIM SinT(360) as Single
DIM CosT(360) as Single
For I = 0 to 360
SinT(I) = Sin(I * (3.1415/180))
CosT(I) = Cos(I * (3.1415/180))
Next
Then you can use it like this...
X = SinT(45) * 10
...instead of this...
X = Sin(45 * 3.1415 / 180) * 10
...which saves you 3 calculations (especially the /)...
The other good use for a Look-up table is divide maps...
Take the max possible number... (such as 255)
Take the number you are going to divide by (such as 5)
and multiply them together... 255 * 5 = 1275
Dim Div5(1275) as integer
For I = 1 to 1275
Div5(I) = I \ 5
Next
This is especially good when dealing with graphics, due to the number of calculations required in a minimum amount of time...
Addition & Subtraction are cheap so you can do this...
avg = Div5(num1 + num2 + num3 + num4 + num5)
...and still save time over this...
avg = (num1 + num2 + num3 + num4 + num5) \ 5
QB + Assembly Language...
The other tip is to look into assembly language, to directly control the computer. For the QB interface, you can use libraries, or CALL ABSOLUTE, and CALL INTERUPT (for QB4.5)
The Ups & Downs...
CALL INTERUPT...
Allows you to access hardware, such as your mouse, within QB...
only allows you to deal with dos interupts...
CALL ABSOLUTE...
allows you to directly use the computers resources...
but, requires the assembly code to be converted to Hex codes...
Assembly Libraries...
Able to use any assembly commands (16 / 32bit)...
You have to assemble your code into an .OBJ file, then use LIB.EXE to create a .LIB and a .QLB file for use in QB, You also have to have QuickBasic 4.5, so you can load the library with the /L option and Compile it.
Have Fun, Be Young... Code BASIC
-Josh Stribling