1Public Class Form1
2 Public Structure DBField
3 Public name As String
4 Public price As Integer
5 End Structure
67 Private h(5) As DBField
89 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
10 With h(0)
11 .name = "コーラ"
12 .price = 150
13 End With
14 With h(1)
15 .name = "コーラ"
16 .price = 200
17 End With
18 With h(2)
19 .name = "コーラ"
20 .price = 300
21 End With
22 With h(3)
23 .name = "コーラ"
24 .price = 500
25 End With
26 With h(4)
27 .name = "コーラ"
28 .price = 10000
29 End With
30 With h(5)
31 .name = "みかんじゅーす"
32 .price = 100
33 End With
34 End Sub
3536 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
37 Dim i = h.OrderBy(Function(a) Guid.NewGuid()).ToArray()
38 Dim j = h.OrderByDescending(Function(a) a.price).ToArray()
39 Print("オリジナル", h)
40 Print("ランダム", i)
41 Print("値段の高い順", j)
42 End Sub
4344 Private Sub Print(title As String, target As IEnumerable(Of DBField))
45 Dim s = target.Select(Function(a) String.Format("name={0}, price={1}", a.name, a.price))
46 MessageBox.Show(title + vbLf + vbLf + String.Join(vbLf, s))
47 End Sub
4849End Class