在屏蔽文本框中输入今天的日期 [英] Enter todays date into a masked text box

查看:52
本文介绍了在屏蔽文本框中输入今天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何在今天的日期或任何日期进入蒙面文本框?



我的默认值是ADate.Mask =## / ## / ## ##

How do yo enter today's date or any date into a masked text box?

My default is ADate.Mask = "##/##/####"

推荐答案

你需要以掩码格式输入它。



示例:





You need to enter it in mask format.

Examples:


MaskedTextBox1.Text = "00/00/0000"




MaskedTextBox1.Text = "01/06/1998"




MaskedTextBox1.Text = "10/15/2013"

< br $> b $ b

---

编辑:

要将系统日期放入屏蔽文本框,请使用此代码< br $> b $ b



---

To put the system date into the masked text box use this code

Dim formated_date = My.Computer.Clock.GmtTime.ToShortDateString
If formated_date.Split("/")(0).Length = 1 Then
   formated_date = "0" & formated_date.ToString
End If

If formated_date.Split("/")(1).Length = 1 Then
formated_date = formated_date.Replace("/" & My.Computer.Clock.GmtTime.Day & "/", "/0" & My.Computer.Clock.GmtTime.Day & "/")
End If

MaskedTextBox1.Text = formated_date


试试这个

Try this
maskedTextBox1.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now);



希望这有帮助


Hope this helps


这篇关于在屏蔽文本框中输入今天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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