PC Review


Reply
Thread Tools Rate Thread

Format() method

 
 
=?Utf-8?B?S2FubmFu?=
Guest
Posts: n/a
 
      30th May 2007
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
 
Reply With Quote
 
 
 
 
Spam Catcher
Guest
Posts: n/a
 
      30th May 2007
=?Utf-8?B?S2FubmFu?= <(E-Mail Removed)> wrote in
news:C3747567-15F8-48D6-8A79-(E-Mail Removed):

> 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.
 
Reply With Quote
 
 
 
 
Al Reid
Guest
Posts: n/a
 
      30th May 2007
"Kannan" <(E-Mail Removed)> wrote in message news:C3747567-15F8-48D6-8A79-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      30th May 2007
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.
 
Reply With Quote
 
Smokey Grindle
Guest
Posts: n/a
 
      30th May 2007
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" <(E-Mail Removed)> wrote in message
news:eIDPx%(E-Mail Removed)...
> "Kannan" <(E-Mail Removed)> wrote in message
> news:C3747567-15F8-48D6-8A79-(E-Mail Removed)...
>> 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
>
>
>



 
Reply With Quote
 
Al Reid
Guest
Posts: n/a
 
      31st May 2007
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:eIDPx%(E-Mail Removed)...
> > "Kannan" <(E-Mail Removed)> wrote in message
> > news:C3747567-15F8-48D6-8A79-(E-Mail Removed)...
> >> 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
> >
> >
> >

>
>



 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      31st May 2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method or data member not found with Move method Kate Microsoft Access Form Coding 2 1st Dec 2004 03:58 PM
Reflection: Determining a Method's Attributes from within the Method Good Enchiladas Microsoft Dot NET Framework 2 15th Apr 2004 01:28 PM
Howto customize "Add Method" wizard on "Add Method" menu of Class View? Bill Smarty Microsoft Dot NET Framework 0 13th Jan 2004 07:54 PM
Re: Method inheriting from base.base.[method]? John Saunders Microsoft Dot NET Framework 2 30th Aug 2003 05:20 PM
define method that takes a method? Michael Lang Microsoft Dot NET Framework 4 13th Aug 2003 04:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:43 PM.