Public Class Shohin Public Property 商品C As Integer Public Property 商品名 As String End Class
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim data() As Shohin ReDim data(2) Dim sw As New System.Runtime.Serialization.Json.DataContractJsonSerializer(GetType(Shohin)) Dim ms As New MemoryStream() Dim output As String For i = 0 To 2 data(i) = New Shohin data(i).商品C = DataGridView1.Rows(i).Cells(0).Value data(i).商品名 = DataGridView1.Rows(i).Cells(1).Value sw.WriteObject(ms, data(i)) Next output = Encoding.UTF8.GetString(ms.ToArray()) TextBox1.Text = output End Sub