vb.net 仅在视觉基础上尝试用今天的日期填充文本框值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29970725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:05:01  来源:igfitidea点击:

Trying to fill textbox value with today's date only on visual basics

vb.netdatetextboxbasic

提问by phpdrivesmemad

I am trying to fill a textbox value with the current date and I do not want the user to be able to change the date. I want to use a textbox and not a datepicker. I would like the form to load with today's date already loaded in the textbox, which I will then use in my insert query.

我正在尝试用当前日期填充文本框值,但我不希望用户能够更改日期。我想使用文本框而不是日期选择器。我希望表单加载今天的日期已经加载到文本框中,然后我将在我的插入查询中使用它。

I want the date format of yyyy-MM-dd to be in the textbox memberregisterationdate.text. I am not sure where on my form I should put the code either.

我希望 yyyy-MM-dd 的日期格式在文本框 memberregisterationdate.text 中。我也不确定我应该把代码放在我的表格的哪个位置。

Really stuck on this and I can't seem to find it anywhere Thanks in advance

真的坚持这一点,我似乎无法在任何地方找到它提前致谢

回答by Tim Schmelter

You have to make it Enabled = Falseto disable it. You can load it in Form_Load:

你必须让它Enabled = False禁用它。你可以加载它Form_Load

memberregisterationdate.Text = Date.Today.ToString("yyyy-MM-dd")