それでは皆様、メリークリスマス!
チャットルーム プログラムの作成中に次のような問題が発生しました。リストビューに項目を追加していますが、最後のサブ項目にテキストを追加しようとすると、InvalidArgument='5' の値は 'index' に対して有効ではありませんというエラーが表示されます。
私は次のことをしました:
msgbox(listview1.subitems.count())
これは 5 を返すので、合計 6 列あることを意味すると仮定します (カウントは 1 - 5 ではなく 0 - 5 から始まります。
何が問題なのですか?コードの残りの部分は次のとおりです。
Sub AddClient(ByVal client As connection, ByVal strings() As String)
Dim l As New ListViewItem(strings)
l.ImageIndex = GetFlag(strings(1).ToLower)
l.Tag = client
numcon1.Text += 1
l.SubItems(5).Text = "test phrase"
l.SubItems(4).Text = strings(7)
addtoconsole(strings(3) & " ~ " & strings(1) & " Has Connected.")
ListView1.Items.Add(l)
If audiocon = "True" Then
My.Computer.Audio.Play("newuser.wav", AudioPlayMode.Background)
Else
End If
If notifcon = "True" Then
NotifyIcon1.ShowBalloonTip(3000, "A friend is online!", strings(3) & " ~ " & strings(1), ToolTipIcon.Info)
End If
End Sub
本当にありがとう!