|
-
Oct 3rd, 2000, 11:29 PM
#1
Thread Starter
Lively Member
I was working on something for Chopper1's post, but it was pretty much junk. My question is, how can I do this without a timer control. I couldn't figure how to code the GetTickCount and make it work. Seemed to be going into an infinite loop, and not even showing the form.
Code:
Private Sub Timer1_Timer() ' interval set to 10
Dim i As Integer
For i = 0 To Shape1.Count - 1 ' I have four squares,
If Shape1(i).Left > 50 Then ' each a little bigger
Shape1(i).Top = Shape1(i).Top - 20 ' than the one inside
Shape1(i).Height = Shape1(i).Height + 40
Shape1(i).Width = Shape1(i).Width + 40
Shape1(i).Left = Shape1(i).Left - 20
Else
Shape1(i).Left = 1800 'innermost square is of these dimensions
Shape1(i).Top = 1680
Shape1(i).Height = 1935
Shape1(i).Width = 2175
End If
Next i
End Sub
If you can answer this, could you show me with this code.
-
Oct 4th, 2000, 02:31 AM
#2
transcendental analytic
If you put the code in form_load event (did you?) then it won't load up the form until it exits the event. Try putting it into Form_Activate
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 4th, 2000, 12:35 PM
#3
Thread Starter
Lively Member
Like this?
Would it be something like this
[CODE]
Private Sub Form1_Activate()
Dim i As Integer
Dim Start As Long
Do While Start < GetTickCount + 10 ' whatever
Start = GetTickCount
For i = 0 To Shape1.Count - 1 ' I have four squares,
If Shape1(i).Left > 50 Then ' each a little bigger
Shape1(i).Top = Shape1(i).Top - 20 ' than the one inside
Shape1(i).Height = Shape1(i).Height + 40
Shape1(i).Width = Shape1(i).Width + 40
Shape1(i).Left = Shape1(i).Left - 20
Else
Shape1(i).Left = 1800 'innermost square is of these dimensions
Shape1(i).Top = 1680
Shape1(i).Height = 1935
Shape1(i).Width = 2175
End If
Next i
Loop
End Sub
-
Oct 4th, 2000, 03:44 PM
#4
Member
Use 'With, End With'
To make your code more compact use "With, end With" like this (also runs faster):
Code:
Private Sub Form1_Activate()
Dim i As Integer
Dim Start As Long
Do While Start < GetTickCount + 10
Start = GetTickCount
For i = 0 To Shape1.Count - 1
With Shape1(i) '<--
If .Left > 50 Then
.Top = .Top - 20
.Height = .Height + 40
.Width = .Width + 40
.Left = .Left - 20
Else
.Left = 1800
.Top = 1680
.Height = 1935
.Width = 2175
End If
End With '<--
Next i
Loop
End Sub
I hope it work to nest it like this, sorry I can´t help you out with API GetTickCount
Balder = Viking God
VB6/VC++ Enterprise Editions
-
Oct 5th, 2000, 06:17 AM
#5
transcendental analytic
Code:
Start = GetTickCount'place this outside your loop or it won't end until something slows down the system :eek:
Do While Start < GetTickCount + 10
For i = 0 To Shape1.Count - 1
With Shape1(i)
If .Left > 50 Then
.Top = .Top - 20
.Height = .Height + 40
.Width = .Width + 40
.Left = .Left - 20
Else
.Left = 1800
.Top = 1680
.Height = 1935
.Width = 2175
End If
End With
Next i
doevents 'threading
Loop while forms.count 'exits when your app closes
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|