0
私のプロジェクトでは、レコードの配列をあらかじめ定義しておき、次の構文を使用して高校のリストボックスに出力させます。syntaxt here "System.Exception: 'Late-bound 'Contact'が後でバインドされた式の結果である場合、値タイプのフィールドへの代入は無効です。 ''レコードの配列を使用する際の問題
多くのトラブルシューティングを試みましたが、問題を見つけることができませんでした。本当にシンプルなもの。私はあなたが提供することができるすべての助けをappriciateと思います。
パブリック・クラスのForm1
'Dim addressbook(8, 2) As String
'Dim number As i
Structure Contact
Dim Forename As String
Dim Surname As String
Dim address As String
End Structure
Dim addressbook(8) As Contact
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
setuprecords(addressbook)
displayoutput(addressbook)
End Sub
Sub setuprecords(ByRef addressbook)
'For row = 0 To 8
' For column = 0 To 2
' If column = 0 Then
' addressbook(row, column) = InputBox("What is your name ")
' ElseIf column = 1 Then
' addressbook(row, column) = InputBox("What is your 2nd name")
' ElseIf column = 2 Then
' addressbook(row, column) = InputBox("What is your address")
' End If
' Next
'Next
addressbook(0).Forename = "Bart"
addressbook(0).Surname = "Simpson"
addressbook(0).address = "Springfeild"
addressbook(1).Forename = "Lisa"
addressbook(1).Surname = "Simpson"
addressbook(1).address = "Springfeild"
addressbook(2).Forename = "Homer"
addressbook(2).Surname = "Simpson"
addressbook(2).address = "Springfeild"
addressbook(3).Forename = "Marge"
addressbook(3).Surname = "Simpson"
addressbook(3).address = "Springfeild"
addressbook(4).Forename = "Santa's Little Helper"
addressbook(4).Surname = "Simpson"
addressbook(4).address = "Springfeild"
addressbook(5).Forename = "Magie"
addressbook(5).Surname = "Simpson"
addressbook(5).address = "Springfeild"
addressbook(6).Forename = "Milhouse"
addressbook(6).Surname = "Something"
addressbook(6).address = "Springfeild"
addressbook(7).Forename = "Ned"
addressbook(7).Surname = "Flanders"
addressbook(7).address = "Springfeild"
addressbook(8).Forename = "Willie"
addressbook(8).Surname = "Something"
addressbook(8).address = "Springfeild"
End Sub
Sub displayoutput(ByVal addressbook)
'If number = 0 Then
' For row = 0 To 8
' ListBox1.Items.Add(addressbook(row, 0) & vbTab & (addressbook(row, 1) & vbTab & (addressbook(row, 2))))
' Next
'Else
' ' ListBox1.Items.Add(addressbook(number - 1 & vbTab & column))
' ListBox1.Items.Add(addressbook(number - 1, 0) & vbTab & (addressbook(number - 1, 1) & vbTab & (addressbook(number - 1, 2))))
'End If
For row = 0 To 8
ListBox1.Items.Add(addressbook(row).Forename)
ListBox1.Items.Add(addressbook(row).Surname)
ListBox1.Items.Add(addressbook(row).address)
Next
End Sub
エンドクラス
ありがとうございました! これはすぐに私の問題を解決しました。私の先生はこれについて私に教えてくれませんでした –