' This VBScript program is written in QBASIC style. It opens a fake console window and ' prints some stuff, and then waits for the user to press the ESC key to exit. ' REMEMBER: When you save this file, it must be saved with a .VBS file extension, not BAS! ' (Tested on Windows XP.) ' Do not remove these lines: ON ERROR RESUME NEXT SET MSIE = WScript.CreateObject("InternetExplorer.Application") WIDTH 80, 15 CLS '''''''''''''''''''''''''''''''''''''''''''''''' ' PROGRAM CODE GOES HERE: PRINT "Press ESC to close this window and terminate the program!" FOR I = 1 TO 10 PRINT I WAIT 30 NEXT DO IF GETKEY(27) = 27 THEN EXIT DO ' WAIT FOR ESC KEY ' IF THE USER CLICKS ON THE "X" TO CLOSE THE WINDOW, ' GETKEY WILL RETURN 27 TO FAKE AN ESC KEYPRESS, ' AND THEN WE EXIT... LOOP SYSTEM ' OTHERWISE THIS LINE CLOSES THE WINDOW. '''''''''''''''''''''''''''''''''''''''''''''''' FUNCTION GETKEY(E) Err.clear GETKEY = MSIE.Document.MAIN.KEYCODE.value IF Err.Number <> 0 THEN GETKEY = E Err.clear ELSE MSIE.Document.MAIN.KEYCODE.value = 0 END IF END FUNCTION SUB CLS MSIE.Document.MAIN.INPUT.value = "" MSIE.Document.MAIN.INPUT.blur END SUB SUB WAIT(MS) WScript.Sleep MS END SUB SUB POPUP(TEXT) WScript.Echo TEXT END SUB SUB PRINT(TEXT) MSIE.Document.MAIN.INPUT.value = MSIE.Document.MAIN.INPUT.value & TEXT & CHR(13) END SUB SUB WIDTH (Cols, Rows) W = Cols * 7.125 + 20 '590 H = Rows * 16 + 20 WAIT 50 MSIE.Visible = 0 MSIE.ToolBar = 0 MSIE.StatusBar = 0 MSIE.FullScreen = 0 MSIE.Navigate("about:blank") MSIE.RegisterAsDropTarget = 0 MSIE.Height = H MSIE.Width = W WAIT 100 MSIE.Top = FIX((MSIE.document.parentWindow.screen.height - H) / 2) MSIE.Left = FIX((MSIE.document.parentWindow.screen.availWidth - W) / 2) WAIT 200 MSIE.Document.open MSIE.Document.write("My BASIC Application
") MSIE.Document.close MSIE.Visible = 1 END SUB SUB SYSTEM Err.clear MSIE.Quit Err.clear END SUB