This question is along the lines of HTML table horizontal spacing
We have an old code base and can not use css. When an entire column in a table is empty, the resulting table is very ugly. We have a text email solution that adds spaces to the end up a word up to the remaining set of characters that you specify using New String. Since New String only takes a char, was seeing what 1 liner, small amount of code examples people could come up with.
We use .net 3.5sp1
Public Function StringSize(ByVal data As String, ByVal size As Short, ByVal usehtml As Boolean) As String
If data.Length > size Then
Return Left(data, size - 4) & "... "
Else
If usehtml Then
'small algorithm here ( & nbsp ; )
Else
Return data & New String(" ", size - Len(data))
End If
End If
End Function
If you really want to pad with
, then – well, frankly – I’m not sure it is a great idea, but something like (excuse the C#):The following is a bad way to do it in one line with LINQ; included only for interest: