タイトル : Re^11: Split関数について 投稿日 : 2010/03/12(Fri) 10:29 投稿者 : 従業員
魔界の仮面弁士 様 おはようございます。大変お世話になります ARRYStr2(1)の値は "*** *** **** ***" です。 これを数行のテキストイメージにするために、ARRYStr2(1)を配列に入れました。 Dim ARRYStr2(5) As String Dim separator As Char() = "" Dim options As StringSplitOptions = StringSplitOptions.RemoveEmptyEntries Dim returnValue As String() Dim ColValue(10) As String Dim I As Integer Dim J As Integer 'Dim A(10) ARRYStr2(1) = "*** *** **** ***" ARRYStr2(2) = "** ** *" ARRYStr2(3) = "* *** * ** **" For I = 1 To 3 returnValue = ARRYStr2(I).Split(separator, options) Debug.WriteLine(Microsoft.VisualBasic.UBound(returnValue)) ColValue(I) = Microsoft.VisualBasic.UBound(returnValue)’要素数 Next I For J = 1 To 3 Dim A()() As String = GetArray(ARRYStr2(ColValue(J))) Next J Dim Cols() As String = A(0) '0行目の内容 Dim Cell As String = Cols(2) 'その行の2列目の内容 Dim Cell As String = A(0)(2) End Sub Private Function GetArray(ByVal s As String) As String()() Dim options As StringSplitOptions = StringSplitOptions.RemoveEmptyEntries Dim lines As New List(Of String()) For Each line As String In Split(s, vbNewLine) lines.Add(line.Split(New String() {}, options)) Next Return lines.ToArray() End Function > 個々の要素は、 > Dim Cols() As String = A(0) '0行目の内容 > Dim Cell As String = Cols(2) 'その行の2列目の内容 > のように取り出せます。これを一行で書くと、 > Dim Cell As String = A(0)(2) |