By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

ToString method - formatting codes?

P: n/a
1) Where can I find the valid set of formatting codes that can be used with
the tostring method?

2) When using the following statement I get an invalid cast error --- why?
X0SS = drResult("X0SS").tostring("f2")
where drResult is a datarow and the value of drResult("X0SS") is 2.75 a
double.
If I change it to the following then no error occurs:
X0SS = cDbl(drResult("X0SS")).tostring("f2")

Oct 1 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Darrell Wesley" <Da***********@discussions.microsoft.comschrieb
1) Where can I find the valid set of formatting codes that can be
used with the tostring method?
In the .Net Framework docs. (Working with base types -Formatting types ->
Numeric Format Strings)
2) When using the following statement I get an invalid cast error
--- why? X0SS = drResult("X0SS").tostring("f2")
where drResult is a datarow and the value of drResult("X0SS") is
2.75 a double.
Maybe because X0SS is not declared as a string.
If I change it to the following then no error occurs:
X0SS = cDbl(drResult("X0SS")).tostring("f2")
What is the type of X0SS?
Armin

Oct 1 '07 #2

P: n/a
X0SS was originally defined as type object I have changed it to type String
but the error remained. The error message said something about not being able
to convert type string to integer??

"Armin Zingler" wrote:
"Darrell Wesley" <Da***********@discussions.microsoft.comschrieb
1) Where can I find the valid set of formatting codes that can be
used with the tostring method?

In the .Net Framework docs. (Working with base types -Formatting types ->
Numeric Format Strings)
2) When using the following statement I get an invalid cast error
--- why? X0SS = drResult("X0SS").tostring("f2")
where drResult is a datarow and the value of drResult("X0SS") is
2.75 a double.

Maybe because X0SS is not declared as a string.
If I change it to the following then no error occurs:
X0SS = cDbl(drResult("X0SS")).tostring("f2")

What is the type of X0SS?
Armin

Oct 1 '07 #3

P: n/a
"Darrell Wesley" <Da***********@discussions.microsoft.comschrieb
X0SS was originally defined as type object I have changed it to type
String but the error remained. The error message said something
about not being able to convert type string to integer??

"Armin Zingler" wrote:
"Darrell Wesley" <Da***********@discussions.microsoft.comschrieb
1) Where can I find the valid set of formatting codes that can
be used with the tostring method?
In the .Net Framework docs. (Working with base types -Formatting
types -Numeric Format Strings)
2) When using the following statement I get an invalid cast
error --- why? X0SS = drResult("X0SS").tostring("f2")
where drResult is a datarow and the value of
drResult("X0SS") is 2.75 a double.
Maybe because X0SS is not declared as a string.
If I change it to the following then no error occurs:
X0SS = cDbl(drResult("X0SS")).tostring("f2")
What is the type of X0SS?

Did you enable Option Strict? If not, do it and solve all compile errors.
Armin
Oct 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.