excel - 用户表单文本框中未填充总公式的百分比?
问题描述
试图让一个标记为的文本框txtPercentage
填充两个文本框值之间的 % 差异txtCurrentHourly
和txtNewHourlyRate
. 为什么txtPercentage
在触发其他对象时我没有填充该值?
Private Sub txtNewHourly_Change()
Dim a As Double, b As Double
Dim txtpercent, c
a = txtCurrentHourly.Value
b = txtNewHourlyRate.Value
txtpercent = (b - a) / a
If Me.cmbHourlyAnnual.Value = "Hourly" Then
If b <> 0 Then
txtpercent
End If
ElseIf Me.cmbHourlyAnnual.Value = "Annual" Then
If b <> 0 Then
txtpercent
End If
End If
txtPercentage.Value = IIf(IsError(txtpercent), "-", txtpercent)
End Sub