此贴专门用来记录,我在VB中写的测试程序,与测试代码
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6945
ClientLeft = 60
ClientTop = 345
ClientWidth = 9045
LinkTopic = "Form1"
ScaleHeight = 6945
ScaleWidth = 9045
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Interval = 100
Left = 3960
Top = 3240
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1080
TabIndex = 0
Top = 3360
Width = 1215
End
Begin VB.Shape Shape2
Height = 735
Index = 0
Left = 8160
Top = 720
Width = 735
End
Begin VB.Shape Shape1
Height = 735
Left = 480
Top = 720
Width = 735
End
Begin VB.Line Line1
X1 = 240
X2 = 8880
Y1 = 1080
Y2 = 1080
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strTmp1 As String
Dim lngTime As Long
Dim strArray1() As String
Dim i1 As Integer, ii2 As Integer
Private Sub Form_Load()
'
strTmp1 = "a,a,a,a,b,b,a,b,b"
i1 = 0
strArray1 = Split(strTmp1, ",")
Call createShape
Debug.Print UBound(strArray1)
Debug.Print Me.Shape2.UBound
lngTime = 0
End Sub
Private Sub Timer1_Timer()
'
Dim l1 As Long
' Call test1
' Call shape_move1
' If i1 >= ii2 Then i1 = 1
' i1 = i1 + 1
Debug.Print i1
Call shape_move2(Me.Shape2(i1))
End Sub
Sub test1()
'
If i1 > 4 Then i1 = 0
i1 = i1 + 1
Me.Shape1.Shape = i1
Print i1
End Sub
Private Sub shape_move1()
'
Me.Shape2(0).Left = Me.Shape2(0).Left - 100
End Sub
Private Sub shape_move2(shpTmp1 As Shape)
'
shpTmp1.Left = shpTmp1.Left - 100
End Sub
Private Sub createShape()
'
Dim i1 As Integer, i2 As Integer
Debug.Print UBound(strArray1)
i2 = 0
For i1 = 0 To UBound(strArray1)
Debug.Print strArray1(i1)
If strArray1(i1) = "a" Then
i2 = Me.Shape2.UBound + 1
Load Shape2(i2)
' Shape2(i2).Left = 0
' Shape2(i2).Top = 0
Shape2(i2).Shape = 2
Shape2(i2).Visible = True
End If
If strArray1(i1) = "b" Then
i2 = Me.Shape2.UBound + 1
Load Shape2(i2)
' Shape2(i2).Left = 0
' Shape2(i2).Top = 0
Shape2(i2).Shape = 4
Shape2(i2).Visible = True
End If
Next i1
ii2 = Me.Shape2.UBound
Debug.Print ii2
End Sub