暱稱: 隨風飄蕩的羽毛 頭銜: [御用]潛水艇
高中生 
- 帖子
- 852
- 主題
- 79
- 精華
- 0
- 積分
- 918
- 點名
- 0
- 作業系統
- Windows 7 , XP
- 軟體版本
- Office 2007, Office 2003,Office 2010,YoZo Office
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 宇宙
- 註冊時間
- 2011-4-8
- 最後登錄
- 2024-2-21
|
[原創] Visual Base 2010 陣列結果 Part 2
程式說明
說明1.此為大範圍陣列區域和Combobox 對應關係,但必須先新增 Combobox 和 Label 各一個。
說明2.這個程式可應用於檔案架管理、機房配置表。
說明3.若有問題可以詢問,但不代表我全會~
執行結果圖片
程式碼區域- Public Class Form1
- Dim bubo1(25, 4) As Button
- Dim chcom As ComboBox
- Dim labcom As Label
- Private Sub Form1_Invalidated(ByVal sender As Object, ByVal e As System.Windows.Forms.InvalidateEventArgs) Handles Me.Invalidated
- With Me
- .Height = 900
- .Width = 1650
- End With
- End Sub
- Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
- Dim usx1, usy1 As Integer
- Dim nn As Integer
- chcom = Me.ComboBox1
- Dim fontFamily As New FontFamily("微軟正黑體")
- Me.Show()
- nn = 1
- For usx1 = 0 To 25
- For usy1 = 0 To 4
- bubo1(usx1, usy1) = New button
- Me.Controls.Add(bubo1(usx1, usy1))
- bubo1(usx1, usy1).BackColor = Color.Aquamarine
- bubo1(usx1, usy1).Width = 37
- bubo1(usx1, usy1).Height = 150
- bubo1(usx1, usy1).AutoSize = False
- bubo1(usx1, usy1).TextAlign = ContentAlignment.MiddleCenter ' 上下左右置中
- bubo1(usx1, usy1).Font = New Font(fontFamily, 12, FontStyle.Regular, GraphicsUnit.Pixel) ' 字體、大小、類型
- bubo1(usx1, usy1).Location = New Point(10 + (43 * usx1), 10 + (155 * usy1))
- 'bubo1(usx1, usy1).Appearance = Appearance.Button '按鈕型態
- bubo1(usx1, usy1).Text = bubo1(usx1, usy1).Name & "第 O 區域" & Chr(10) & "第" & " " & nn & " " & "區塊"
- '分隔線'
- chcom.Items.Add(bubo1(usx1, usy1).Text)
- nn = nn + 1
- Next
- Next
- usx1 = Nothing
- usy1 = Nothing
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- labcom = Me.Label1
- 'labcom.Text = Me.chcom.Text
- If Me.chcom.Text <> "" Then
- 'MsgBox(Me.chcom.Text) '& Chr(10) & Me.bubo1(25, 4).Text)
- If (InStr(Me.chcom.Text, "塊") >= 1) Then
- 'MsgBox(Me.chcom.Text & Chr(10) & "在第" & InStr(Me.chcom.Text, "塊") & "位") '& Chr(10) & Mid(Me.chcom.Text, 10, 1))
- End If
- For aaa = 1 To 2
- For usx1 = 0 To 25
- For usy1 = 0 To 4
- If bubo1(usx1, usy1).Text = Me.chcom.Text Then
- labcom.Text = bubo1(usx1, usy1).Text
- bubo1(usx1, usy1).BackColor = Color.DarkSalmon
- ElseIf bubo1(usx1, usy1).Text <> Me.chcom.Text Then
- bubo1(usx1, usy1).BackColor = Color.Aquamarine
- End If
- Next
- Next
- Next
- End If
- End Sub
- End Class
複製代碼 |
|