VBA

Moderators: PavlinII
Number of threads: 1673
Number of posts: 3078

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Declaring Variables - Help needed please Posted by sheeps on 8 May 2002 at 12:52 PM
Ive just started programming and am not sure why this wont work!!
Is it because i havent declared the variables??
Can someone help please.
Nick




Dim direction As String


Private Sub Command1_Click()
direction = "up"
End Sub

Private Sub Command2_Click()
direction = "down"
End Sub

Private Sub Command3_Click()
direction = "left"
End Sub

Private Sub Command4_Click()
direction = "right"
End Sub

Private Sub Command5_Click()
Menu.Show
Unload Me
End Sub

Private Sub Form_Load()
direction = "still"
End Sub

Private Sub Timer1_Timer()

Select Case direction
Case "up"
Shape2.Top = Shape2.Top - 20
Case "down"
Shape2.Top = Shape2.Top + 20
Case "right"
Shape2.Left = Shape2.Left + 20
Case "left"
Shape2.Left = Shape2.Left - 20
End Select

For i = 0 To 9
If Shape2.Top + Shape2.Height > Shape1(i).Top And Shape2.Top < Shape1(i).Top + Shape(i).Height And Shape2.Left + Shape2.Width > Shape1(i).Left And Shape2.Left < Shape1(i).Left + Shape1(i).Width Then
MsgBox "HIT"
Shape2.Top = 240
Shape2.Left = 120
direction = "still"
End If
If Shape2.Top + Shape2.Height > Shape3.Top And Shape2.Top < Shape3.Top + Shape3.Height And Shape2.Left + Shape2.Width > Shape3.Left And Shape2.Left < Shape3.Left + Shape3.Width Then
MsgBox "Made It"
Shape2.Top = 240
Shape2.Left = 120
direction = "still"
End If
Next i
End Sub

Report
Re: Declaring Variables - Help needed please Posted by Gazzalad on 10 May 2002 at 12:44 AM
In your last bit of code you have:

For i = 0 To 9
If Shape2.Top + Shape2.Height > Shape1(i).Top And Shape2.Top < Shape1(i).Top + Shape(i).Height And Shape2.Left + Shape2.Width > Shape1(i).Left And Shape2.Left < Shape1(i).Left + Shape1(i).Width Then

In there you have Shape(i), but I can not see that used anywhere else. Should it be Shape1(i) or Shape2(i)???

G



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.