ToString method - formatting codes?

G

Guest

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")
 
A

Armin Zingler

Darrell Wesley said:
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
 
G

Guest

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??
 
A

Armin Zingler

Darrell Wesley said:
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??


Did you enable Option Strict? If not, do it and solve all compile errors.


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top