在 VB6 中,是否有自动生成的验证事件代码? [英] In VB6, is there an autogenerated code for the Validate Event?

查看:9
本文介绍了在 VB6 中,是否有自动生成的验证事件代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VB6 中,文本框的 CausesValidation 属性默认设置为 True.在这种情况下,当 Validate 事件触发时,是否还有一些自动生成的验证代码?我想这种自动生成的代码至少会检查该字段是否为非空.

In VB6, textboxes have their CausesValidation property set to True by default. In this case, is there some autogenerated validation code as well when the Validate Event fires? I suppose that such autogenerated code would check, at a minimum, whether the field is non-empty.

推荐答案

要回答您的问题,没有与 TextBox 验证事件关联的自动生成的验证代码.您必须编写自己的代码,您可以在其中检查 TextBox 的 Text 属性的内容等.

To answer your question, no there is no autogenerated validation code associated with the TextBox Validation event. You'll have to write your own where you can check the contents of a TextBox's Text property, etc.

您可能会发现以下内容很有用:

You might find the following useful:

CausesValidation 属性和验证事件 - Visual Basic6 文本框控件

如果您想知道如何验证 TextBox 是否为非空",您可以使用链接中的以下验证事件示例:

If you're wondering how you might verify that a TextBox is 'non-empty' you might use the following validation event example from the link:

Private Sub txtRequired_Validate(Cancel As Boolean)
    ' Check that field is not empty.
    If txtRequired.Text = "" Then 
        MsgBox "Please enter something here", vbExclamation
        Cancel = True
    End If
End Sub

这篇关于在 VB6 中,是否有自动生成的验证事件代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆