I have a TextBox on a UserForm that displays the results of calculations done inside the UserForm's code. I build up a string using the concatenate operator along with spaces (" ") and the values. When all calculations are finished, I print a report similar to the following:
The problem is that the length of input 1, input 2, input N strings can be variable, but I still want all columns to line up in the TextBox. The way to solve this using C/C++ would be to use a field width specifier such as the following:
Where an appropriate field width is chosen based on the expected size of the strings.
Does something similar exist in Excel VBA? I suppose I could manually go through each string and pad the end with as many spaces as it would take to give the desired length, but that seems kind of tedious.
Code:
input output 1 output 2 output 3
-------------------------------------------
input 1 value 1-1 value 1-2 value 1-3
input 2 value 2-1 value 2-2 value 2-3
...
input N value N-1 value N-2 value N-3
The problem is that the length of input 1, input 2, input N strings can be variable, but I still want all columns to line up in the TextBox. The way to solve this using C/C++ would be to use a field width specifier such as the following:
Code:
printf("%-20s%-10s%-10s\n", value1[1], value1[2], value1[3]);
Where an appropriate field width is chosen based on the expected size of the strings.
Does something similar exist in Excel VBA? I suppose I could manually go through each string and pad the end with as many spaces as it would take to give the desired length, but that seems kind of tedious.