I googled for this, but VB.Net (2008) doesn't seem to allow inserting formatting characters (eg. \t, \r\n) in String.Format:
'BAD MessageBox.Show(String.Format("{0}{tab}{1}", "Foo", "Bar"))
'BAD MessageBox.Show(String.Format("{0}\t{1}", "Foo", "Bar"))
MessageBox.Show(String.Format("{0}" & vbTab & "{1}", "Foo", "Bar"))
Is there an easier way to build a formatted string that must contain formatting characters?
"Easier" is probably in the eye of the beholder, but here is a different way:
MessageBox.Show(String.Join(vbTab, {"Foo", "Bar"}))
I also came up with this:
MessageBox.Show(String.Format("{0}\t{1}\t{2}", "Foo", "Bar", "Test").Replace("\t", vbTab))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With