We recently noticed that the vb.net CStr function yields different
results than the vb6 version when converting SQL decimal data. If, for
example, the data is defined in SQL as decimal(19,10), the vb.net CStr
function will return ten digits to the right of the decimal,
regardless of the data value. In this case, if the data value is 5,
the vb.net CStr function will return 5.0000000000. The vb6 CStr
function will simply return 5. In other words, the vb.net CStr
function always returns digits the length of the scale value after the
decimal. The vb6 CStr function will not return the trailing zeroes.
Why?
Thanks, Bill 9 7698
Try using ToString() instead. It's inherited from Object. CStr is actually
using the Microsoft.VisualBasic library which may or may not cause problems.
ToString() is the *correct* .NET way to do it (you cuould also use CType,
but ToString just makes it easier in most cases)
HTH,
CJ
"Bill L." <bl****@penson.com> wrote in message
news:50**************************@posting.google.c om... We recently noticed that the vb.net CStr function yields different results than the vb6 version when converting SQL decimal data. If, for example, the data is defined in SQL as decimal(19,10), the vb.net CStr function will return ten digits to the right of the decimal, regardless of the data value. In this case, if the data value is 5, the vb.net CStr function will return 5.0000000000. The vb6 CStr function will simply return 5. In other words, the vb.net CStr function always returns digits the length of the scale value after the decimal. The vb6 CStr function will not return the trailing zeroes. Why?
Thanks, Bill
"Bill L." <bl****@penson.com> wrote in message
news:50**************************@posting.google.c om... We recently noticed that the vb.net CStr function yields different results than the vb6 version when converting SQL decimal data.
Bill,
I gave up on VB4's CStr() function many, /many/ moons ago, being
too lazy to have to thank about the leading space that positive values
are tagged with (reserved for a minus sign on nagative numbers, of
course). I /invariably/ used Format() to convert numbers into Strings
which, in .Net, means <value>.ToString( <format> ).
HTH,
Phill W.
Hi CJ,
I see I am in the opposition toDay.
toString() is the from C languages derived method to do it.
(The only one I use by the way)
Cor
I never said I was 100% correct. =)
BTW, have you read some of the conversations from msmobiles in the
smartphone group.
Now that is some funny stuff. He bashes the EU alot... Not that its funny
he's bashing the EU, but his "evidence" supporting his theories is funny.
=)
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ua*************@TK2MSFTNGP11.phx.gbl... Hi CJ,
I see I am in the opposition toDay.
toString() is the from C languages derived method to do it.
(The only one I use by the way)
Cor
> BTW, have you read some of the conversations from msmobiles in the smartphone group.
Now that is some funny stuff. He bashes the EU alot... Not that its
funny he's bashing the EU, but his "evidence" supporting his theories is funny.
I was looking, however was only suprissed that Bill Vaughn was involved in
that newsgroup for the rest nothing intresting. Did not see that on the EU,
however for me it seems to be a kid.
I wish often the times that especially Nak was doing those things but much
better in this newsgroup where there again.
Cor
* "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> scripsit: I gave up on VB4's CStr() function many, /many/ moons ago, being too lazy to have to thank about the leading space that positive values are tagged with (reserved for a minus sign on nagative numbers, of
I think you are talking about the 'Str' function, not 'CStr'.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
* "CJ Taylor" <[cege] at [tavayn] dit commmmm> scripsit: ToString() is the *correct* .NET way to do it (you cuould also use CType, but ToString just makes it easier in most cases)
There is no "correct .NET way", there is only personal preference.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
As it turns out, I am able to use ToString instead of CStr if I
explicitly convert the data value to Object using CType(I don't
necessarily know what the data type is being returned from SQL, I'm just
blindly converting to String). Thanks for the suggestion. This is, of
course, preferable.
The behavior is, however, the same. To see for yourself, return from SQL
a value of decimal data type and simply convert it to string.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
FINE!! JUST F*#(*$@! be that way then!
j/k
=)
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de... * "CJ Taylor" <[cege] at [tavayn] dit commmmm> scripsit: ToString() is the *correct* .NET way to do it (you cuould also use
CType, but ToString just makes it easier in most cases)
There is no "correct .NET way", there is only personal preference.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Penn Markham |
last post by:
Hello all,
I am writing a script where I need to use the system() function to call
htpasswd. I can do this just fine on the command line...works great
(see attached file, test.php). When my...
|
by: Ronald W. Roberts |
last post by:
I'm having a problem understanding the Round function. Below are quotes
from two
books on VB.NET. The first book shows examples with one argument and
how it
rounds. The second book something...
|
by: Paul |
last post by:
Anyone have code that emulates the Nz function in Microsoft Access?
In Access it is:
Nz(Value as variant, Optional ValueIfNull as Variant) as Variant
|
by: Vol |
last post by:
I think 'atan' can get the angle but it is not the four quadrant angle.
Is there any function that i can get the angle from -pi to pi? or I
have to use some if ... else?
I know in Matlab, we use...
|
by: karthi |
last post by:
hi,
I need user defined function that converts string to float in c.
since the library function atof and strtod occupies large space in
my processor memory I can't use it in my code.
regards,...
| |
by: Sean |
last post by:
Book I am reading says that Cstr() is best method for efficency and safety
however it doesnt compare that method of the .ToString() method.
Which is best.
Thanks
|
by: Csaba Gabor |
last post by:
I feel like it's the twilight zone here as several seemingly trivial
questions are bugging me.
The first of the following three lines is a syntax error, while the
last one is the only one that...
|
by: John |
last post by:
Hi
I have a WinForm app with a bound form. When user enters a value in field
rateid I lookup the respective rate amount from a table and assign it to
field rate.I am using the DLookup function...
|
by: coolguyaroundyou |
last post by:
See the below code:
void func(int x)
{
printf("%d",x);
}
int main()
{
int j=0;
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |