gpt4 book ai didi

excel - 用户表单文本框必填字段 - 仅接受数字模式

转载 作者:行者123 更新时间:2023-12-04 21:46:40 26 4
gpt4 key购买 nike

我需要帮助尝试制作 excel userform textbox 以仅接受数字模式。我的数字模式是 12 位数字。00.4 位数字或 8 位数字,因此 textbox 应该只接受类似于 772344456566.00.0001 或 77186238 的数字。
我已经搜索过类似问题的线索,但没有人给我任何方向。
我当前的代码是这样的,但不接近我的目标:

Private Sub Textbox3_Exit(ByVal Cancel As MsForms.ReturnBoolean)
IF TextBox3.Value <>"" Or TextBox3.Value < 0 Then
MsgBox "Invalid sales order number"
TextBox3.SetFocus
End If
End Sub

最佳答案

尝试这个:

Private Sub Textbox3_Exit(ByVal Cancel As MsForms.ReturnBoolean)
If Not TextBox3.Value Like "########" Or _
Not TextBox3.Value Like "############.00.####" Then
MsgBox "Invalid sales order number"
TextBox3.SetFocus
End If
End Sub
和/或查看 This .基本上,当与 Like 一起使用时运算符, #检查任何数字,所以 ##检查 2 位数字等。

关于excel - 用户表单文本框必填字段 - 仅接受数字模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63631588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com