# Converting Text to Single

S B used Ask the Experts™
on
TT as a Text is equal
TT= "970531101235"
Then converted in P6 as below
P6 = CSng(TT)
Now P6 is equal 9.705311E+11
Which after formatting as below;
C6 = Format(P6, "#,####")
It is equal  970531100000
And truncated so the last 5 digits converted to zero.
I want to convert TT to a complete Number(970531101235 Single Percision).
How could I solve the problem?
Comment
Watch Question

Do more with

EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Older than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
``````Sub S()
Dim TT As String
TT = "970531101235"

With Range("P6")
.NumberFormat = "0"
.Value = CSng(TT)
End With
End Sub
``````
Retired IT Professional
Commented:
Why not use CDbl(TT)?
Distinguished Expert 2017

Commented:
I think that Decimal might hold this value as a number but Long Integer, Single, and Double will not.  Here's a good reference for Access data types.  Bookmark it.

http://www.databasedev.co.uk/fields_datatypes.html

Generally "numbers" this long are not actually numbers at all but codes.  You only need to store data in a numeric data type if you need to do arithmetic with it.  If you have long, variable length codes, you need to store them right justified by using leading zeros or spaces so they will sort and compare correctly.  Otherwise as straight text, 9 will be larger than 10 and will sort after 10.  Also after 100,000,000.000 because text fields are compared left to right; character by character.
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
A Single cannot hold the precision needed.
So you must use Double or Decimal:

``````TT = "970531101235"
P6 = CDbl(TT)  ' or: P6 = CDec(TT)

? Format(P6, "#,###")
970,531,101,235
``````
Also, you might be able to use TT "as is":

``````? Format(TT, "#,###")
970,531,101,235
``````

Commented:
Thanks to all
Simply I used CDbl() and it solved
I could do some summation operations after conversion
Good luck

Do more with

Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.