VB6 Format() equivalent

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
 
E

Eduardo A. Morcillo [MS MVP VB]

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".
 
H

Herfried K. Wagner [MVP]

* "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'.
 

aru

Joined
Feb 27, 2012
Messages
4
Reaction score
0
Hi,
What is the Equivalent Functionality form VB6 to VB.net for this Format Function

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

can anybody Help me.


Aru
 

aru

Joined
Feb 27, 2012
Messages
4
Reaction score
0
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"​
 

aru

Joined
Feb 27, 2012
Messages
4
Reaction score
0
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
 

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

Top