VBA 文本框输入掩码 [英] VBA text box input mask

查看:63
本文介绍了VBA 文本框输入掩码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文本框中有两个日期和时间验证,如下所示:

I have two validation for date and time as below in text boxes:

00/00\ 00:00;0;0;_

它需要 (dd/mm hh:mm) 并且工作正常

It will take (dd/mm hh:mm) and works fine

但有时我把

34/34 56:78 需要,但不应该

34/34 56:78 it will take , But it shouldn't

日期不得超过 31 月 12 日 24 分和 59 分

Date sholdnot go beyond 31, month 12 time 24 and minute 59

请帮忙

推荐答案

我昨天刚遇到信用卡到期日期字段的这个问题.我愚蠢地将 00/0000 作为输入掩码更改为 00/00,并遇到了您遇到的问题.问题是,如果第二对数字是有效日期,它将被解释为日期,并默认提供当前年份.因此,如果您输入:

I just encountered this problem with a Credit Card expiration date field yesterday. I'd stupidly changed 00/0000 as input mask to 00/00, and encountered the problem you're having. the issue is that if the second pair of digits is a valid date, it will be interpreted as a date and the current year will be supplied tacitly. Thus, if you enter:

  06/09

对于 2009 年 6 月,它将存储为:

for Jun 2009, it will be stored as:

  06/09/2009

另一方面,如果您输入:

On the other hand, if you enter:

  06/34

它将被解释为

  06/01/1934

据我所知,您想要做的事情的唯一方法就是使用 4 位数字年份.

So far as I can see, the only way for you to do what you want is to use a 4-digit year.

这篇关于VBA 文本框输入掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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