473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Format() method

hi,

I would like to add $ symbol in numeric amount. For that I have used
Microsoft.VisualBasic.Strings.Format(strAmount, "$0.00").

But it seems to me that I am using VisualBasic name space and my manager
wants to use .Net name space function instead of VisualBasic. Is there is any
function availble for this in .Net?

Sorry I am new to .Net hence I am not sure about this.

Regards,
Ramesh
May 30 '07 #1
6 1785
=?Utf-8?B?S2FubmFu?= <Ka****@discussions.microsoft.comwrote in
news:C3**********************************@microsof t.com:
But it seems to me that I am using VisualBasic name space and my
manager wants to use .Net name space function instead of VisualBasic.
Is there is any function availble for this in .Net?
String.Format.
May 30 '07 #2
"Kannan" <Ka****@discussions.microsoft.comwrote in message news:C3**********************************@microsof t.com...
hi,

I would like to add $ symbol in numeric amount. For that I have used
Microsoft.VisualBasic.Strings.Format(strAmount, "$0.00").

But it seems to me that I am using VisualBasic name space and my manager
wants to use .Net name space function instead of VisualBasic. Is there is any
function availble for this in .Net?

Sorry I am new to .Net hence I am not sure about this.

Regards,
Ramesh
Why does your manager let you program VB if there is an aversion to using the VisualBasic namespace? I really don't understand that
position.
--
Al Reid

May 30 '07 #3
Kannan wrote:
I would like to add $ symbol in numeric amount. For that I have used
Microsoft.VisualBasic.Strings.Format(strAmount, "$0.00").

But it seems to me that I am using VisualBasic name space and my manager
wants to use .Net name space function instead of VisualBasic.
Why? Are you writing Visual Basic code or not?
If you are, then the /compiler/ will be using stuff from
Microsoft.VisualBasic under the covers - you're not saving or gaining
anything by ignoring the functionality that's provided for you.
If you want to go down that road, write in C#.
Is there is any function availble for this in .Net?
Well, yes, there is but, looking at your code, you need to be careful.

Imports VB = Microsoft.VisualBasic

Dim s as String _
= VB.Strings.Format( strAmount, "$0.00" )

You're relying on Evil Type Coercion to convert "strAmount" from a
String into a numeric value, before formatting it using a numeric
formatting pattern. AFAIK, none of the .Net methods will do this;
you'll have to do the conversion yourself, as in

Dim d as Double _
= CDbl( strAmount ) ' I know; I'm terrible :-)
Dim s as String _
= d.ToString( "$0.00" )

HTH,
Phill W.
May 30 '07 #4
VisualBasic namespace is really just for legacy stuff and converted
projects... if you want to code in "true" .NET you should not use it and
find the real way to do it from the System namespace down.. you never know
when MS may ditch the VisualBasic namespace
"Al Reid" <ar*****@reidDASHhome.comwrote in message
news:eI****************@TK2MSFTNGP03.phx.gbl...
"Kannan" <Ka****@discussions.microsoft.comwrote in message
news:C3**********************************@microsof t.com...
>hi,

I would like to add $ symbol in numeric amount. For that I have used
Microsoft.VisualBasic.Strings.Format(strAmount, "$0.00").

But it seems to me that I am using VisualBasic name space and my manager
wants to use .Net name space function instead of VisualBasic. Is there is
any
function availble for this in .Net?

Sorry I am new to .Net hence I am not sure about this.

Regards,
Ramesh

Why does your manager let you program VB if there is an aversion to using
the VisualBasic namespace? I really don't understand that
position.
--
Al Reid

May 30 '07 #5
I believe you are quite mistaken. The VisualBasic.Compatibility namespace is there for that purpose. If you don't like VB, then
switch to C#.

--
Al Reid
"Smokey Grindle" <no****@nospam.comwrote in message news:uC*************@TK2MSFTNGP06.phx.gbl...
VisualBasic namespace is really just for legacy stuff and converted
projects... if you want to code in "true" .NET you should not use it and
find the real way to do it from the System namespace down.. you never know
when MS may ditch the VisualBasic namespace
"Al Reid" <ar*****@reidDASHhome.comwrote in message
news:eI****************@TK2MSFTNGP03.phx.gbl...
"Kannan" <Ka****@discussions.microsoft.comwrote in message
news:C3**********************************@microsof t.com...
hi,

I would like to add $ symbol in numeric amount. For that I have used
Microsoft.VisualBasic.Strings.Format(strAmount, "$0.00").

But it seems to me that I am using VisualBasic name space and my manager
wants to use .Net name space function instead of VisualBasic. Is there is
any
function availble for this in .Net?

Sorry I am new to .Net hence I am not sure about this.

Regards,
Ramesh
Why does your manager let you program VB if there is an aversion to using
the VisualBasic namespace? I really don't understand that
position.
--
Al Reid



May 31 '07 #6
Smokey Grindle wrote:
VisualBasic namespace is really just for legacy stuff and converted
projects... if you want to code in "true" .NET you should not use it and
find the real way to do it from the System namespace down.. you never know
when MS may ditch the VisualBasic namespace
I would beg to differ.

The Microsoft.VisualBasic./Compatibility/ assembly contains all the
"old" stuff that we really /shouldn't/ be bothering with any more -
fixed length strings and such like (yuk!).

The Microsoft.VisualBasic assembly is part and parcel of the language,
like it or not - it's even used by the Visual Basic /compiler/, under
the covers. Just see /if/ you can compile a V.B. assembly that
/doesn't/ have a dependency on this assembly!

(and, if you /haven't/ got to VB'2005 yet, just what /is/ the "true
..Net" version of

ReDim Preserve myArray( 22 )

??

Regards,
Phill W.
May 31 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: marwa mohamed | last post by:
salamo alikom hi all when i run report that includes image control linked to a field in the table that contains the image path(on the server)and the record source of the report contains over 30...
5
by: Tom Pair | last post by:
Hi, I use DateTime.Now to display the current date and time. For instance, it's default format is 2003-10-29 21:23:36. How can I change the format as follows? 10/29/2003 9:23:36 PM ...
1
by: Mark | last post by:
Hi, how would I translate this to c#? char ttext; sprintf(ttext,"%2.2i %-.10s %8.3f",1,"Mark",123.24); 01 Mark<6spaces> 123.240 Thanks
9
by: Phill | last post by:
: string.Format("MyString {0}", var); : String str = "MyString {0}"; str.Format(var); In otherwords why is Format a method of the string class but it can't
2
by: Kenneth | last post by:
Hi, I have installed VS.NET 2000 on an english version of windows 2000 professional and in control panel I've chosen Regional Options and on the general Tab I have Swedish in Your...
3
by: Mike | last post by:
I need to update a table with a phone number and have the phone number like (800)555-1212 how can I put ( ) around the area code in the update process?
7
by: tolisss | last post by:
Hi i have a string like "22/5/2006 12:00:00 pµ" and i want to create a string like "05/22/06" could someone please
6
by: JFB | last post by:
Hi all, How can I format a fax number as 888-333-444? The number is coming from database as 8883334444 <ItemTemplate> <%#container.dataItem("cfax")%> </ItemTemplate> Tks JFB
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
5
by: phhonl | last post by:
Dim x As String x = Format$("50", "00000000") in vb6 x returns "00000050" in vb.net 2005 x returns "0000000" How do I get the vb6 result in vb.net 2005?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.