Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help needed with formatting a single number

3 views
Skip to first unread message

louisryder23

unread,
Jan 23, 2009, 9:01:24 AM1/23/09
to
1. I have a Single column with Precision 4 and Scale 2 , in a table in
a SQL Server database, with the value 1.00 (maximum possible value in
this column is 99.99)

2. Using VB, what is most efficient way to format this to a string so
that I can get:
0100

Examples of input and output are:

1.10 -> 0110
1.20 -> 0120
1.39 -> 0139

Here is the code I already have and it works but IMHO is a bit crude:

'sinVersion is a Single variable with the field value
String.Format( "{0:00.00}" , sinVersion ).Replace( "." , "" )


Any suggestions for optimization ?

Thanks in advance,
Louis

MikeD

unread,
Jan 23, 2009, 9:18:26 AM1/23/09
to

"louisryder23" <louisr...@gmail.com> wrote in message news:589b21c0-fec5-4a21...@f40g2000pri.googlegroups.com...

> 1. I have a Single column with Precision 4 and Scale 2 , in a table in
> a SQL Server database, with the value 1.00 (maximum possible value in
> this column is 99.99)
>
> 2. Using VB, what is most efficient way to format this to a string so
> that I can get:
> 0100
>
> Examples of input and output are:
>
> 1.10 -> 0110
> 1.20 -> 0120
> 1.39 -> 0139
>
>
>
> Here is the code I already have and it works but IMHO is a bit crude:
>
> 'sinVersion is a Single variable with the field value
> String.Format( "{0:00.00}" , sinVersion ).Replace( "." , "" )


It looks like you are using VB.NET. This newsgroup is for VB "Classic" (VB6 and under). Please post to a newsgroup having "dotnet"
or "vsnet" in its name.

--
Mike


Auric__

unread,
Jan 23, 2009, 8:16:24 PM1/23/09
to
On Fri, 23 Jan 2009 14:01:24 GMT, louisryder23 wrote:

> Here is the code I already have and it works but IMHO is a bit crude:
>
> 'sinVersion is a Single variable with the field value
> String.Format( "{0:00.00}" , sinVersion ).Replace( "." , "" )
>
> Any suggestions for optimization ?

Replace sinVersion with (sinVersion * 100), something like this:
String.Format( "{0:0000}" , (sinVersion * 100) )

--
Money is the root of all wealth.

louisryder23

unread,
Jan 25, 2009, 8:59:55 AM1/25/09
to
On Jan 24, 3:16 am, "Auric__" <not.my.r...@email.address> wrote:

[.......]


> Replace sinVersion with (sinVersion * 100), something like this:
>   String.Format( "{0:0000}" , (sinVersion * 100) )
>
> --
> Money is the root of all wealth.


That's brilliant!

Thanks,
Louis Ryder

Auric__

unread,
Jan 26, 2009, 3:11:41 PM1/26/09
to
On Sun, 25 Jan 2009 13:59:55 GMT, louisryder23 wrote:

> On Jan 24, 3:16 am, "Auric__" <not.my.r...@email.address> wrote:
>
>> Replace sinVersion with (sinVersion * 100), something like this:
>>   String.Format( "{0:0000}" , (sinVersion * 100) )
>

> That's brilliant!

Did it work?

--
Down that path lies madness.
On the other hand, the road to hell is paved with melting snowballs.
-- Larry Wall

Auric__

unread,
Jan 26, 2009, 3:15:52 PM1/26/09
to
On Sun, 25 Jan 2009 13:59:55 GMT, louisryder23 wrote:

> On Jan 24, 3:16 am, "Auric__" <not.my.r...@email.address> wrote:
>
>> Replace sinVersion with (sinVersion * 100), something like this:
>>   String.Format( "{0:0000}" , (sinVersion * 100) )
>

Auric__

unread,
Jan 26, 2009, 8:08:04 PM1/26/09
to
On Mon, 26 Jan 2009 20:15:52 GMT, Auric__ wrote:

> On Sun, 25 Jan 2009 13:59:55 GMT, louisryder23 wrote:
>
>> On Jan 24, 3:16 am, "Auric__" <not.my.r...@email.address> wrote:
>>
>>> Replace sinVersion with (sinVersion * 100), something like this:
>>>   String.Format( "{0:0000}" , (sinVersion * 100) )
>>
>> That's brilliant!
>
> Did it work?

Stupid friggin' Xnews [mumble grumble] damn double post!

--
You'd have better luck trying to artificially inseminate a brick.

0 new messages