ToString method - formatting codes?

  • Thread starter Thread starter Guest
  • Start date Start date
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")
 
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
 
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??
 
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
 
Back
Top