首页 > 解决方案 > 用户表单文本框中未填充总公式的百分比?

问题描述

试图让一个标记为的文本框txtPercentage填充两个文本框值之间的 % 差异txtCurrentHourlytxtNewHourlyRate. 为什么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

标签: excelvbauserform

解决方案


推荐阅读