當前位置:編程學習大全網 - 編程軟體 - VB課設,在水平線上畫壹個勻速滾動的車輪,車輪的外觀自行決定,可以

VB課設,在水平線上畫壹個勻速滾動的車輪,車輪的外觀自行決定,可以

'添加控件Timer1,Shape1.Line1

'左鍵向左移動 右鍵向右移動,上鍵加速.下鍵減速

'空格暫時|開始

Dim Speed As Integer

Dim Pos As Boolean

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode

Case 40 '按下鍵減速

Speed = IIf(Speed > 15, Speed - 15, 15)

Case 38 '按上鍵加速

Speed = IIf(Speed < 150, Speed + 15, 150)

Case 39 '右鍵向右

Pos = False

Case 37 '左鍵向左

Pos = True

Case 32 '空格鍵開始或暫停

Timer1.Enabled = Not Timer1.Enabled

End Select

End Sub

Private Sub Form_Load()

Speed = 50

Timer1.Interval = 100

Timer1.Enabled = False

Me.AutoRedraw = False

With Line1

.X1 = 600

.X2 = 7000

.Y1 = 2200

.Y2 = 2200

End With

With Shape1

.Shape = 3

.Left = 120

.Height = 1215

.Width = 2295

.Top = 1000

End With

End Sub

Private Sub Timer1_Timer()

Cls

Print "當前速度:" & Speed

Print "方向:" & IIf(Pos, "左", "右")

Shape1.Left = Shape1.Left + IIf(Pos, -Speed, Speed)

End Sub

  • 上一篇:ABB變頻器ACS800與S7-300通訊,選擇pp05 ,51號參數組中的51.05之後的參數怎麽設定,又是什麽意思
  • 下一篇:搬易通叉車故障碼283
  • copyright 2024編程學習大全網