number to string

number to string

Anonymous
Not applicable
479 Views
6 Replies
Message 1 of 7

number to string

Anonymous
Not applicable
Im trying to grab certain decimal places of a double and put them into a string.
I want to convert 0.315 to 315 as a string, likewise .062 will be 062 and .25, 250, etc.
Any idea how this can be done?
0 Likes
480 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
StringVal = str(0.062*1000)
0 Likes
Message 3 of 7

Anonymous
Not applicable
that works except for the case when the number is less than .1. for example as i said if the number was .062 i would need the string to be 062 not 62, not sure how much that would change this.
0 Likes
Message 4 of 7

Anonymous
Not applicable
How about this?

StringVal = Format((str(0.062 * 1000)), "000")
0 Likes
Message 5 of 7

Anonymous
Not applicable
Give this a try
Sub GrabDecimalOnly()
Dim dblNum As Double
Dim decStr As String
dblNum = 0.062
decStr = Mid(CStr(dblNum), 3, 4)
MsgBox decStr
End Sub

Fatty

~'J'~ Message was edited by: Fatty
0 Likes
Message 6 of 7

Anonymous
Not applicable
Hi,

Try this:
x = your numeric value
If Instr CStr(x),".") > 0 then
MsgBox Left$(Split(CStr(x), ".")(1) & "000", 3)
Else
MsgBox "000"
End If


--

Laurie Comerford
CADApps
www.cadapps.com.au
wrote in message news:5261068@discussion.autodesk.com...
Im trying to grab certain decimal places of a double and put them into a
string.
I want to convert 0.315 to 315 as a string, likewise .062 will be 062 and
.25, 250, etc.
Any idea how this can be done?
0 Likes
Message 7 of 7

Anonymous
Not applicable
all the different variations seem to do the trick, thanks guys
0 Likes