Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports 9.0 - Using the Conversion Type 1

Status
Not open for further replies.

trafficstudent

Programmer
Oct 21, 2005
106
US
Could anyone point me a good direction with this issue. I have never found a great answer to this question : When do i need to use the conversion type tonumber or totext in crystal? The reason im azking is that i want to better understand the strenghts of CR when using variable or tables.

If possible when answering this question could you use an example.

I ahve look in the help section but really didn't understand why or when to use it.

Thanks in advance
 
You use them to convert from numbers or text to the other...

I don't really understand why the help didn't clarify this.

It shows exact examples of how to use it. It does NOT show examples of when to use it because that is based on your needs, not a generic application of them.

Tonumber and cdbl are the same, and similar to the VAL function.

Totext is the same as cstr

Are you going to post every function in Crystal asking what they are and when you might use them?

If you have real requirements, please don't hesitate to post them, asking people to explain to you what a number and text is wastes their time, go read and test...

-k
 
What SV said...but as this is a forum to share information here is a couple of examples:

If you have a field that is only numbers but is stored in the Table as a string field you would use:

ToNumber({String Field});

Now you would be able to use said value for any arithmetic or for sorting numerically.

Now let's say you have the opposite, you need to add a number into a string value. you would use ToText:

"I have " + ToText({sum of apples},0) + " apples ";

As I have recently learned depending on your version of CR, you could just use the "&" and you would not need to convert the data type:

"I have " & {sum of apples}& " apples ";
 
Note that the totext should probably be:

totext({table.field},0,"")

Again, use the help and go through the samples, those given above are a very small sampling of what they can do (and look at VAL in lieu of TONUMBER), and the reasoning stated is obvious.

If you want to do this like a big kid, as opposed to the sort that inappropriately does everything in Crystal , use Views, SPs, or SQL Expressions and allow the server to return the data already in the proper data type and format.

It's faster, unloads the processing and code to the database server where it should be, and will likely allow for more flexibility, reusability and ease of maintenance.

If your dba stores numerics in a string field, or vice-versa, place a cantankerous electric eel in their coffee mug and while they're convulsing uncontrollably, run them through the paper shredder.

Or I suppose you could just fire them, but where's the fun in that?

This is usually the result of legacy databases, or hacks operating as database deevelopers.

-k
 
If your dba stores numerics in a string field, or vice-versa, place a cantankerous electric eel in their coffee mug and while they're convulsing uncontrollably, run them through the paper shredder. "

I had to take over a system that has 2 datatypes: DateTime and String (Some of the fields Names are: Requisition NUMBER, Facility NUMBER, Dept NUMBER.......)

If I could find the DBA who created the system I would have done a lot worse ; )
 
Very sorry you feel this way synapsevampire i didn;t mean to wast your time. I thought that someone could point me in the right direction on how to use this function more efficiently. All i was looking for was website suggestion.

I didn;t mean to wast your time at all, again im truly sorry.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top