Porting Classic Code to Modern BASIC
38.1 GW-BASIC / 8-bit BASIC → QB64-PE checklist
Line numbers + GOTO loops DO...LOOP, FOR...NEXT, WHILE...WEND SUB Name (params) / FUNCTION IF X THEN 200 block IF... END IF ON X GOTO 100, 200, 300 SELECT CASE X Two-letter variable names descriptive names + OPTION _EXPLICIT arrays of TYPE POKE 53280, 0 (C64 border)
COLOR, CLS, _RGB32(...), or simply remove PEEK(197) / GET A$ INKEY$, _KEYHIT, _KEYDOWN Empty FOR delay loops _DELAY, _LIMIT, TIMER PRINT CHR$(147) (clear screen) Graphics via POKE / machine code SCREEN _NEWIMAGE, LINE, _PUTIMAGE HGR, HPLOT (Applesoft) SCREEN, PSET, LINE RND (after RANDOMIZE TIMER)
38.2 A porting workflow
Get the original running unchanged (QB64-PE accepts line numbers, or use PC-BASIC/an emulator) and record its output for a few inputs.
Replace machine-specific statements (POKE, CALL, cursor control characters) with portable equivalents.
Add OPTION _EXPLICIT and declare all variables; rename cryptic variables.
Convert GOSUB blocks into SUBs and GOTO loops into structured loops, one region at a time, re-testing after each change.
Remove line numbers once nothing references them.
Improve: arrays of TYPEs, files instead of DATA for changeable content, modern graphics and input.
38.3 QBasic → FreeBASIC
Easiest: fbc -lang qb prog.bas compiles most QBasic programs unchanged.
For -lang fb: declare all variables (Dim), remove variable suffixes, change INTEGER to Short where 16-bit behavior matters, replace GOSUB with Sub, use Sleep ms semantics, and replace DEF SEG/PEEK/POKE with pointers.
QB64-only _ keywords need FreeBASIC equivalents (_NEWIMAGE → ScreenRes/ImageCreate, _RGB32 → RGB, _DISPLAY → ScreenLock/ScreenUnlock, _LIMIT → Sleep).
38.4 QBasic/VB6 → VB.NET
No direct conversion tool exists for modern .NET; port by hand, module by module.
Arrays are zero-based; default parameter passing is ByVal; Integer is 32-bit; Variant becomes Object; Set is gone; error handling becomes Try...Catch; file I/O moves to System.IO; graphics move to System.Drawing/WinForms/WPF.