向标签添加值和文本-VBA
我需要在VBA中添加一个变量和一些文本(在本例中为“%”)。以下代码不起作用:向标签添加值和文本-VBA,vba,ms-access,Vba,Ms Access,我需要在VBA中添加一个变量和一些文本(在本例中为“%”)。以下代码不起作用: Private Sub Form_Load() Dim CurrentValue As String CurrentValue = DLookup("AvgOfutil_MPS", "AverageDescending", "[dates]") Me.Label34.Caption = Round(CDbl(CurrentValue), 2) + "%" End Sub 我想知道您是否
Private Sub Form_Load()
Dim CurrentValue As String
CurrentValue = DLookup("AvgOfutil_MPS", "AverageDescending", "[dates]")
Me.Label34.Caption = Round(CDbl(CurrentValue), 2) + "%"
End Sub
我想知道您是否定义了一个字符串,然后根据该字符串计算一个Double。你为什么不马上用Double 对于您的问题,正如Alex K.提到的:尝试用“&”连接。尝试下面的内容
Private Sub Form_Load()
Dim CurrentValue As String
CurrentValue = DLookup("AvgOfutil_MPS", "AverageDescending", "[dates]")
Me.Label34.Caption = Cstr(Round(CDbl(CurrentValue), 2)) & "%"
End Sub
不以什么方式工作?
CurrentValue
的值是多少?(始终使用&
非+
进行字符串连接)(始终使用¬+进行字符串连接)-工作完美,谢谢!!!我认为DLookup返回字符串值,所以我可以将其转换为数字。在我的例子中,CurrentValue类似于21.2354325。我马上就用双倍的。顺便说一句,“&”帮助:)