473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

ToString method - formatting codes?

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
3 3881
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34...
1
by: Kevin | last post by:
Hello, Does anyone know how to implement find and replace in a RichTextBox in a way that does not lose the text formatting? As a first attempt I tried rtb.Rtf.Replace(sFindText,...
8
by: G.Ashok | last post by:
Hi, I have created CultureInfo object and specified required digit grouping in it. The one of the overloaded ToString methods of Decimal type has parameters to format the value with required...
7
by: Steven D'Aprano | last post by:
I have a sinking feeling I'm missing something really, really simple. I'm looking for a format string similar to '%.3f' except that trailing zeroes are not included. To give some examples: ...
4
by: Greg Collins [Microsoft MVP] | last post by:
Will DateTime.Now.ToString("s") ALWAYS return the same formatting (i.e. the sortable XML Schema style formatting) regardless of what culture the operating system is set to? I've done limited...
31
by: Zytan | last post by:
Everything (er, every class) in C# has ToString() which is conveniently automatically invoked when using it in Debug.WriteLine() or in a string concatenation, etc. I made a struct, and I want to...
4
by: J Miro | last post by:
When I use ToString method to format the value of a nullable numeric variable, I get "No overload for method 'ToString' takes '1' arguments" error message. Example: Int32? myNum = 12345; ...
5
by: Bob | last post by:
Hello Folks, I am bring backa data reader dr from the database/ So I have a number of fields such as dr To put this in a table I use "<td>" + dr.ToString() + "</td>" But I want to...
11
by: Gary James | last post by:
I'm using an object data type variable to pass a numeric value (Int, Float, Double, etc) to a function that returns a formatted string. However, nullable types do not provide an overridden...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.