[英]VBA userform message box
我目前有一个消息框的以下代码
'Message box to ensure that the accounting format equals the loan withdrawl country
If txtloanwithcountry = "England" Then
NumberFormat = "_(£* #,##0.00_);_(£* (#,##0.00);_(£* ""-""??_);_(@_)"
Else
MsgBox "The currency used in the loan withdrawl country must be equal to number format"
End If
但是,我想知道如何输入所有使用英镑的国家,所以当我输入威尔士,苏格兰,北爱尔兰-爱尔兰或英国时,数字格式是英镑吗? 当我输入其他国家/地区时,将显示消息框。 我试图使用Or语句,但是它不起作用。
当您执行“ Or
您需要包括整个比较。 所以看起来像
If txtLoanWithCountry = "England" Or txtLoanWithCountry = "Scotland" or txtLoanWithCountry = "Wales" Then
另一种方法是创建一个数组,然后使用Filter函数查看您所在的国家/地区是否在该数组中。 如果Filter返回的Ubound为-1,则找不到匹配项。
Dim vaPounds As Variant
'Create the array of countries
vaPounds = Split("England Northern-Ireland Scotland Wales")
If UBound(Filter(vaPounds, txtLoanWithCountry)) = -1 Then
MsgBox "The currency used in the loan withdrawl country must be equal to number format"
Else
NumberFormat = "_(£* #,##0.00_);_(£* (#,##0.00);_(£* ""-""??_);_(@_)"
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.