How set to show only 2 decimal places?

How set to show only 2 decimal places?

ladimirabdala
Advocate Advocate
562 Views
3 Replies
Message 1 of 4

How set to show only 2 decimal places?

ladimirabdala
Advocate
Advocate
Here is my code to get a 3d point.
How set to only 2 decimal places in this code?
Thank's in advance.

Private Sub CommandButton1_Click()
Dim returnPnt As Variant
Dim coordenada As String

UserForm1.Hide

' Return a point using a prompt
returnPnt = ThisDrawing.Utility.GetPoint(, "Entre com um ponto: ")
MsgBox "O ponto é : " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2) & vbCrLf

UserForm1.Show
End Sub
0 Likes
563 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Here is one possible way:
(not tested though)

Dim str1 as string, str2 as String, str3 as string
str1 = ThisDrawing.Utility.RealToString(returnPnt(0) ,acDecimal, 2)
str2 = ThisDrawing.Utility.RealToString(returnPnt(1) ,acDecimal, 2)
str3 = ThisDrawing.Utility.RealToString(returnPnt(2) ,acDecimal, 2)
MsgBox "O ponto é : " & str1 & ", " & str2 & ", " & str3 & vbCrLf

Fatty

~'J'~
0 Likes
Message 3 of 4

humbertogo
Advocate
Advocate
use the Round Function

returnPnt = ThisDrawing.Utility.GetPoint(, "Entre com um ponto: ")
MsgBox "O ponto é : " & Round(returnPnt(0), 2) & ", " & Round(returnPnt(1), 2) & ", " & Round(returnPnt(2), 2) & vbCrLf
0 Likes
Message 4 of 4

ladimirabdala
Advocate
Advocate
Thank's guys.
The code now is very good!!!
Regards.
0 Likes