validation - 验证 Excel VBA 中的文本框
问题描述
我有一个包含多个文本框的表单。我使用以下过程来验证活动文本框是否没有留空。如果是这样,那么文本框将重置为值 0 并且它可以工作
子 UFDataEntryCheckValue()
With UF_DataEntry.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Or UF_DataEntry.ActiveControl.Value = vbNullString Then
MsgBox "Input must be a number and can not be blank"
UF_DataEntry.ActiveControl.Value = 0
End If
End With
但是,有一个文本框需要重置为 36 的值,当我将以下语句添加到上述过程中时,出现错误
Dim Ctrl As Control
With UF_DataEntry.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Or UF_DataEntry.ActiveControl.Value = vbNullString Then
MsgBox "Input must be a number and can not be blank"
'.Value = vbNullString
If Ctrl.Name = "DE_Text_Term" Then
Ctrl.Value = 36
Else: UF_DataEntry.ActiveControl.Value = 0
End If
End If
End With
解决方案
推荐阅读
- c# - 有没有办法用 JObject SelectTokens 选择 MAX 值?
- ssis-2012 - SSIS 连接管理器
- c++ - 如何将深度 = 17 的 DicomImage(Dcmtk) 转换为 Mat(Opencv) 对象?
- java - 如何自动重新连接到 XMPP 服务器?
- java - Hibernate 将关联映射为映射
- eclipse - 多个模块的 GWT+ Maven 和 Eclipse 编译
- informatica - 使用 informatica 存储库表查询以获取从源到目标的字段到字段逻辑
- sql - 转换 DATE 会返回“无效月份”错误
- java - Logstash-logback 事件特定的自定义字段(使用 StructuredArguments)未添加到 JSON
- c - 从单个文件描述符多路复用到两个文件描述符