''' <summary> ''' CSVを入力します。 ''' </summary> ''' <param name="FileName_str">ファイル名</param> ''' <param name="Object_To">処理対象のコントロール</param> Private Sub Input_CSV(ByVal FileName_str As String, ByVal Object_To As ListView) 'CSV入力 Dim Reader As IO.StreamReader '読み込み処理 Reader = New IO.StreamReader(FileName_str, System.Text.Encoding.GetEncoding("shift_jis")) Dim ReadedTxt() As String = Split(Reader.ReadToEnd, vbCrLf ) Reader.Close() Dim ListViewItemArray(UBound(ReadedTxt) - 1) As ListView.ListViewItemCollection For i = 0 To UBound(ReadedTxt) - 1 Dim str() As String = Split(ReadedTxt(i), ",") Dim Into As String() = {str(0), str(1)} ListViewItemArray(i).Add(New ListViewItem(Into)) Next Object_To.BeginUpdate() 'ListView追加処理 'ListViewItemCollectionから追加したい... Object_To.EndUpdate() End Sub
''' <summary> ''' CSVを入力します。 ''' </summary> ''' <param name="FileName_str">ファイル名</param> ''' <param name="Object_To">処理対象のコントロール</param> Private Sub Input_CSV(ByVal FileName_str As String, ByVal Object_To As ListView) 'CSV入力 Dim Reader As IO.StreamReader Dim ListItemArray As New ArrayList '読み込み処理 Reader = New IO.StreamReader(FileName_str, System.Text.Encoding.GetEncoding("shift_jis")) Dim ReadedTxt() As String = Split(Reader.ReadToEnd, vbCrLf ) Reader.Close() For i = 0 To UBound(ReadedTxt) - 1 Dim str() As String = Split(ReadedTxt(i), ",") Dim Into As String() = {str(0), str(1)} ListItemArray.Add(Into) Next Object_To.BeginUpdate() 'ListView追加処理 For Each Into As String() In ListItemArray Object_To.Items.Add(New ListViewItem(Into)) Next Object_To.EndUpdate() End Sub