VB6 Format() equivalent

  • Thread starter Thread starter Matthew Hood
  • Start date Start date
M

Matthew Hood

I'm in the transition on moving from VB6 to VB.NET, and I'm having a hard
time finding the equivalent Format function for VB.NET.

example: ?Format("1000.1234567", "0.00##") would return "1000.1235"
Though the example, I just used numeric values. My routine will need to
handle all string obects.

Currently, I'm using the VB6 compatibility function Format, though I would
like to use the preferred VB.NET function. I looked at the String.Format
function, but got a little confused and I'm not sure if this does the same
thing.

Can anybody help me?
TIA,
-Matt
 
I looked at the
String.Format function, but got a little confused and I'm not sure if
this does the same thing.

String.Format does the same that VB6 Format function does and a little more.
Look in the help files for "Composite Formatting", "Standard Numeric Format
Strings", "Custom Numeric Format Strings", "Standard DateTime Format
Strings" and "Custom DateTime Format Strings".
 
* "Matthew Hood said:
example: ?Format("1000.1234567", "0.00##") would return "1000.1235"
Though the example, I just used numeric values. My routine will need to
handle all string obects.

Currently, I'm using the VB6 compatibility function Format, though I would

There is no "compatibility" function 'Format'. 'Format' is part of
VB.NET, so why don't use it?

In the .NET Framwework, have a look at 'String.Format'.
 
Hi,
What is the Equivalent Functionality form VB6 to VB.net for this Format Function

Format$("123", "@@@@@")

can anybody Help me.


Aru
 
Hi,
What is the Equivalent Functionality form VB6 to VB.net for this Format Function

Format$("123", "@@@@@")

can anybody Help me.


Aru

Answer:
VB6 character placeholder in VB.net for "@"

left-justify or right-justify using string.Format().
Dim str1,str2 As String
str1 = string.Format("{0,-5}", 123);
// s = "123 "

str2 = string.Format("{0,5}", 123);
// s = " 123"​
 
Answer:
VB6 character placeholder in VB.net for "@"

left-justify or right-justify using string.Format().
Dim str1,str2 As String
str1 = string.Format("{0,-5}", 123);
// s = "123 "

str2 = string.Format("{0,5}", 123);
// s = " 123"​

Aravinda
 
Back
Top