■63893 / inTopicNo.5) |
Re[3]: vb2008で席替え表を作りたい。 |
□投稿者/ 魔界の仮面弁士 (72回)-(2012/10/25(Thu) 10:57:47)
|
■No63890 (mizu さん) に返信
> ※イメージとしてはこのような図になります。
似たような画面にしてみました。手抜き実装なので、
望んでいる画面構成とは異なるかもしれませんが。
空のフォームに以下のコードを貼って実行してみてください。
Public Class Form1
'人の一覧
Private people() As String = { _
"User01", "User02", "User03", "User04", _
"User05", "User06", "User07", "User08", _
"User09", "User10", "User11", "User12", _
"User13", "User14", "User15", "User16", _
"User17", "User18", "User19", "User20", _
"User21", "User22", "User23", "User24", _
"User25", "User26", "User27", "User28", _
"User29", "User30", "User31", "User32", _
"User33", "User34", "User35", "User36", _
"User37", "User38", "User39", "User40"}
'コントロール作成処理:通常はデザイン時に実施
Private WithEvents Button1 As Button
Private WithEvents ListBox1 As ListBox
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.Font = New Font("MS Gothic", 12)
Button1 = New Button() With {.Text = "shuffle", .Dock = DockStyle.Top}
ListBox1 = New ListBox() With {.MultiColumn = True, .Dock = DockStyle.Fill}
Controls.Add(ListBox1)
Controls.Add(Button1)
ListBox1.DataSource = people
End Sub
'並び替え処理
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
' http://dobon.net/vb/dotnet/programing/arrayshuffle.html
ListBox1.DataSource = people.OrderBy(Function(x) Guid.NewGuid()).ToArray()
End Sub
End Class
|
|