syntax to format text output to a textbox {0}?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 arrays of data that I need to output to a textbox. Pseudocode here

For Each s In arr1
txt1.SelectedText = s & "{0}" & arr2(i)
i += 1
Next

Even though the values in arr1 may have the same length, they vary in size
due to different chars.

abcdefg 12345
ABCDEFG 12345

Needs to be

abcdefg 12345
ABCDEFG 12345

Does anyone know the correct syntax to achieve this kind of formatting?

Thanks
Rich
 
Well, I stumble onto this which sort of works:

txt1.SelectedText = s & ControlChars.Tab & arr2(8) & vbcrlf

Is there a way to control how big/wide a space is for each Tab char? Now I
get

abcdefg 12345
ABCDEFG 12345

I would like to get

abcdefg 12345
ABCDEFG 12345

Thanks
 
Rich said:
I have 2 arrays of data that I need to output to a textbox. Pseudocode
here

For Each s In arr1
txt1.SelectedText = s & "{0}" & arr2(i)
i += 1
Next

Even though the values in arr1 may have the same length, they vary in size
due to different chars.

abcdefg 12345
ABCDEFG 12345

Needs to be

abcdefg 12345
ABCDEFG 12345

Does anyone know the correct syntax to achieve this kind of formatting?


\\\
Me.TextBox1.Text = _
"abcdefg" & ControlChars.Tab & "12345" & _
"ABCDEFG" & ControlChars.Tab & "12345"
///
 
Rich said:
txt1.SelectedText = s & ControlChars.Tab & arr2(8) & vbcrlf

Is there a way to control how big/wide a space is for each Tab char? Now
I
get

abcdefg 12345
ABCDEFG 12345

I would like to get

abcdefg 12345
ABCDEFG 12345

You may want to use a richtextbox control instead of the textbox:

\\\
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Me.RichTextBox1.Text = _
"Hallo" & ControlChars.Tab & _
"Welt" & ControlChars.Tab & _
"Bla"
End Sub

Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles Button1.Click
Me.RichTextBox1.SelectAll()
Me.RichTextBox1.SelectionTabs() = _
New Integer() {100, 200, 300}
End Sub
///
 
first off string.format is your friend...

string.format("My test {0}","value for 0")

second if you want text to work like that you'd need a fixed width font to
start with.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top