- UID
- 109565
- 帖子
- 99
- 主題
- 9
- 精華
- 0
- 積分
- 7
- 楓幣
- 1354
- 威望
- 5
- 存款
- 0
- 贊助金額
- 0
- 推廣
- 0
- GP
- 7
- 閱讀權限
- 10
- 性別
- 保密
- 在線時間
- 30 小時
- 註冊時間
- 2015-8-8
- 最後登入
- 2022-11-6
|
本周為製作跑馬燈
使用軟體為visual basic 2015
物件陣列_跑馬燈
製作之程式碼
Public Class Form1
Dim lamp(99) As Label
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim x, y As Int16
For i As Int16 = 0 To 99
lamp(i) = New Label
x = i Mod 10
y = i \ 10
With lamp(i)
.Width = 10
.Height = 10
.BorderStyle = BorderStyle.FixedSingle
.Top = 11 * y + 20
.Left = 11 * x + 75
.BackColor = Color.Black
End With
Me.Controls.Add(lamp(i))
Next
Button1.Text = "亮下一個燈"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Static i, j As Int16
lamp(j).BackColor = Color.Black
lamp(i).BackColor = Color.Red
i = i + 1
j = i - 1
If i = 100 Then i = 0
End Sub
|
|