very basic VB programming

HubbaHubba

New Member
my teacher is a knob. end of story there .. all i need to a little ball going across the screen when you press the different arrow keys

i'm going to try to alter it from there so im just asking for the basics .. thanks!
 
What version of VBasic are you using?

I'll see if I can dig a piece of code out of one of my old
programs.
I haven't done any programming with vbasic in a year or so,
I'll have to jog my brain again.:eek:
 
In VB6 put a timer(Timer1) and a coloured circular shape(shpBall) with Backstyle 1-opaque on the form and write this.

Option Explicit
Dim intHor As Single
Dim intVert As Single

Private Sub Form_Activate()
intVert = 2
intHor = 2
shpBall.Top = 50
shpBall.Left = 50
Form1.ScaleHeight = 100
Form1.ScaleWidth = 100
End Sub


Private Sub Form_Resize()
Form1.ScaleHeight = 100
Form1.ScaleWidth = 100

End Sub

Private Sub Timer1_Timer()

shpBall.Move shpBall.Left + intHor, shpBall.Top + intVert
If shpBall.Left > 95 Then intHor = intHor * -1
If shpBall.Top > 85 Then intVert = intVert * -1
If shpBall.Left <= 0 Then intHor = intHor * -1
If shpBall.Top <= 0 Then intVert = intVert * -1

End Sub
 
OK I found one:

Place a circle on the form (shpBall) with Backstyle 1-opaque and 3 command buttons(cmdLeft,cmdRight,cmdQuit).



Private Sub cmdLeft_Click()

Do
shpBall.Left = shpBall.Left - 1
DoEvents
Loop Until shpBall.Left <= 0
End Sub

Private Sub cmdQuit_Click()
End
End Sub

Private Sub cmdright_Click()

Do
shpBall.Left = shpBall.Left + 1
DoEvents
Loop Until shpBall.Left = Form1.Width - shpBall.Width
End Sub
 
Back
Top