Public Function GetItem(ByVal s as String, itm as integer) as String
Dim sa() as string
sa = split(s, chr(13))
if (sa.Length < itm) then
return("")
end if
Return sa(itm)
End Function
Then your expression would be same on every item but you would vary the index:
The Value expression for the text box ‘Textbox26’ refers directly to the field ‘Description’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.
Can you make it three columns? I don’t know how to do multiple columns in SSRS from an array. Unfortunately, SSRS only recognizes a subset of HTML and the table element is not one of them.
I have used a mono-spaced font (like Courier) and some spacing logic to get the same effect but mixing fonts does look like someone who just got a new Macintosh in 1994.
Public Function ConvertToTable(ByVal s as String,itm as integer) as String
Try
Dim sa() as string
sa = split(s, chr(13))
Return sa(itm)
Catch
End Try
End Function
If the original goal is just to make a long narrow string appear as multiple columns - and that you don’t need the individual elements - just break it into 3rds.
The first row of this is the original data (one long string with CR’s embedded in it)
The second row is a rectangle with three text boxes in it (TextboxCol1, TextboxCol2, and TextboxCol3).
And MUCH cleaner as a a Report function. You’d use the same call in each columns expression. Just modify the colNum parameter. =Code.ColText(Variables!st.Value, vbCrLf, 1, 3)
' s : string to splt,
' delim: delimiting string
' colNum: the column to return (1 is first col, 2, is 2nd, etc)
' colCount: the number of columns to split it into
' returns a string of text for the specified colNum
Public Function ColText(s As String, delim As String, colNum As Integer, colCount As Integer) As String
Dim retVal As String = ""
Dim rowCount As Integer, i As Integer
If (s.Split(delim).Length = 0) OR colCount = 0 OR colNum > ColCount Then Return s
rowCount = s.Split(delim).Length / colCount
For i = 1 to rowCount
if(s.Split(delim).Length) > (i-1 + ((colNum-1) * rowCount)) Then
retVal = retVal + s.Split(delim)(i-1 + ((colNum-1) * rowCount))
Else
Exit For
End If
Next i
Return retVal
End Function