从文本框中提取数据并进行更新

时间:2014-07-15 10:14:14

标签: excel vba excel-vba

我想从用户表单的文本框中提取数据并使用它进行计算。

我不确定如何做到这一点。

This is currently how the user form looks.

如您所见,当用户在单选按钮上按“是”时,将在总费用下显示一个数字。与从组合框中选择内容时相同。

我想要做的是当用户输入一个数字(在一个设定范围之间)时,它将计算该数字,再乘以另一个数字。

提前致谢。

1 个答案:

答案 0 :(得分:0)

Private Sub OptionButton2_Change()
    TextBox2.Text = ""
End Sub

Private Sub OptionButton1_Change()
    TextBox1.Text = ""
End Sub

Private Sub TextBox1_Change()
    If OptionButton1.Value = True Then
        If TextBox1.Text <> "" Then
            TextBox2.Text = TextBox1.Text * 10
        End If
    ElseIf OptionButton2.Value = True Then
        If TextBox1.Text <> "" Then
            TextBox2.Text = TextBox1.Text * 20
        End If
    End If
End Sub