標題:
[原創]
Visual Base 2010 陣列結果 Part 2
[打印本頁]
作者:
mark15jill
時間:
2012-12-10 16:02
標題:
Visual Base 2010 陣列結果 Part 2
程式說明
說明1.此為大範圍陣列區域和Combobox 對應關係,但必須先新增 Combobox 和 Label 各一個。
說明2.這個程式可應用於檔案架管理、機房配置表。
說明3.
若有問題可以詢問,但不代表我全會~
執行結果圖片
[attach]13487[/attach]
[attach]13488[/attach]
程式碼區域
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
複製代碼
作者:
kenkid
時間:
2015-5-17 23:26
陣列控制項產生...有趣
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)