Question:
qbasic to Visual Basic 2005 express code help?
mrkleen340
2007-08-25 05:58:45 UTC
I made a brick/breakout game in Microsoft QuickBasic (qbasic) but I am now trying to learn Visual Basic. Can anyone tell me the following qbasic codes equivalent in VB.

cls
line
paint
circle
for ... next
do .. loop
addition
subtraction
print
the left and right arrow keys
sleep

p.s. I am brand new to visual basic, however I have been programming in several other programing languages and server side scripting for a few years. So I understand programming concepts, but I know nothing about visual basic.
Three answers:
Einstein
2007-08-25 08:33:07 UTC
Please use the MSDN search tool: http://msdn2.microsoft.com/en-us/default.aspx

________________________________________________________________





1) cls:

http://search.msdn.microsoft.com/search/Default.aspx?query=clear%20screen&brand=msdn&locale=en-us&refinement=00&lang=en-us

How to clear a screen with a teal background:

Example: e.Graphics.Clear(Color.Teal);

________________________________________________________________



2) line

The System.Drawing namespace contains a Pen, Brushes, SolidBrush, and a TextureBrush class.

Example:

'Draw a line using a red pen

Dim redPen As New Drawing.Pen(Color.Red)

e.Graphics.DrawLine(redPen, 5, 5, 200, 200)________________________________________________________________



3) paint

Create a fill:

Dim rect As New Drawing.Rectangle(50, 50, 200, 200)

Dim redBrush As Drawing.SoliBrush = System.Drawing.Brushes.Red

e.Graphics.FillEllipse(redBrush, retc)

__________

4) circle

See also other Graphics object methods DrawEllispe, DrawRectangle, DrawLine

________________________________________________________________



5) for ... next:

For intCounter = intStart To intEnd

Loop

________________________________________________________________



6) do .. loop

Do [{While Until} condition]

statements

[Exit Do]

[statements]

Loop

---

Do

[statements]

[Exit Do]

[statements]

Loop [{While | Until}condition]

________________________________________________________________



7) addition: same

________________________________________________________________



8) subtraction: same

________________________________________________________________



9) print: ?

________________________________________________________________



10) the left and right arrow keys (virtual key codes)"



-------

http://msdn2.microsoft.com/en-us/library/ms959632.aspx



VK_LEFT 25 LEFT ARROW key

VK_UP 26 UP ARROW key

VK_RIGHT 27 RIGHT ARROW key

VK_DOWN 28 DOWN ARROW key

-------



How To Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys:

http://support.microsoft.com/kb/177674

-------



The SendInput function synthesizes keystrokes, mouse motions, and button clicks.



SendInput Function, supercedes keybd_event function



(SEE http://msdn2.microsoft.com/en-us/library/ms646310.aspx)

--------



keybd_event Function (SEE also SendKeys() function)



The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function.

________________________________________________________________



11) sleep: (SEE http://support.microsoft.com/kb/158175)



DoEvents is a Visual Basic function that yields execution so the operating system can process other events. This function cleans out the message loop and executes any other pending business in the Visual Basic runtime. Upon completing the pending business execution, the function calls the Sleep function with zero (0) as the argument so that the remaining time slice can be used to check the queue.

------



The Sleep 32-bit API function is a subset of the DoEvents function. The Visual Basic program calling the function and the Visual Basic runtime executable and interactions with Windows are immediately put to sleep by this function. The programs remain inactive for the time in milliseconds specified in the Sleep argument.



The Sleep function allows you to specify the amount of time your applications are inactive. The DoEvents function returns control to the Visual Basic program after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.



_______________________________
2016-04-01 18:59:07 UTC
The express edition is cut down for personal use, to get used to the package and for you to learn to program. If you want to make applications for other people you will either have to buy the Pro edition, learn C, C++ or something similar and get a compiler. I know VB is easy to learn but MS need to make some money for their efforts... pitiful though they may be sometimes.
2007-08-25 11:28:49 UTC
sorry i'd like know the equivalent of the statement if....then....else

ps i'm a total beginner in V basic.....i'm sorry if i've asked for something stupid.....

bye


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...