在vba中格式化数字

在vba中格式化数字,vba,numbers,format,Vba,Numbers,Format,如何在VBA中将输出数字格式化为特定的小数位数 我有 Label5.Caption = ((a^3)-(pi*((b/2)^2)*a))*c & Format(Label5.Caption, "##0.00") 但这是行不通的。正确的格式是什么 谢谢试试这个 Dim strTemp As String Range("A1").NumberFormat = "0.000" 'or any other format you need Cells(1, 1) = 4 ' the nu

如何在VBA中将输出数字格式化为特定的小数位数

我有

Label5.Caption = ((a^3)-(pi*((b/2)^2)*a))*c & Format(Label5.Caption, "##0.00")
但这是行不通的。正确的格式是什么

谢谢

试试这个

 Dim strTemp As String

 Range("A1").NumberFormat = "0.000" 'or any other format you need
 Cells(1, 1) = 4 ' the number you want
 strTemp = Range("A1").Text
 Label5.Caption

您的
标签5.标题中的值是多少?你用什么小数点分隔符呢?
或者
?它现在是如何工作的,它输出了什么。我想这是正确的方法:Label5.Caption=Format((a^3)-(pi*a*((b/2)^2))*c,“######00.0000”)