【发布时间】:2021-02-04 23:15:23
【问题描述】:
我正在创建一个具有 2 个文本框和 1 个组合框的 VBA 表单。
我想创建以下条件。
当用户尝试更改组合框值而没有先将金额放入 2 文本框中时。
我想显示一条消息,例如“文本框需要有值”,不允许用户继续。
Sub TextBoxnull()
If Len(TextBoxnull.txtTOPDtotalrem.Value) = 0 And Len(TextBoxnull.txtTOPDmedical.Value) > 0 Then
MsgBox "Number must be entered to continue!"
End If
TextBoxnull.cboTOPDsuperannuationperc.Value = Format(TextBoxnull.cboTOPDsuperannuationperc.Value, "0%")
Sheet1.Range("B10").Value = Format(TextBoxnull.cboTOPDsuperannuationperc.Value, "0%")
With TextBoxnull
.txtTOPtaxableremexclsuperannuation.Value = Format(Sheet1.Range("B13").Value, "$#,##0.00;-$#,##0.00")
.txtTOPsuperannuationcontribution.Value = Format(Sheet1.Range("B14").Value, "$#,##0.00;-$#,##0.00")
.txtTOPDtotalremnet.Value = Format(Sheet1.Range("B15").Value, "$#,##0.00;-$#,##0.00")
End With
End Sub
【问题讨论】: