2个简单的问题 [英] 2 easy questions

查看:75
本文介绍了2个简单的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题1

我有两种形式,比如Form1和Form2。 Form2上有datetimepicker控件

。在Form2的Load Event中,我已将

datetimepicker控件的默认值设置为NOW。因此,当我打开表单时,

默认值设置为今天的日期。现在我有时也会从

Form1调用Form2。好的,现在这是我的问题。实际上当我从内部调用Form2

Form1时,我想将datetimepicker控件的值设置为

else。我编写了以下代码来从form1调用form2并设置datetimepicker控件的

值:


Dim frm As Form2

frm = New Form2

frm.dtbDOB.value =" 1/1/2005"

frm.showdialog()


我知道这种情况正在发生,因为当我从form1调用form2时,即使

我设置了dtbDOB控件的值但它被覆盖的值覆盖了

活动。


我该怎么办?


问题2

DateTimePicker的Text属性的目的是什么控制?


问题3.

为什么我在属性窗口中看不到Text属性,但

当我创建一个表单的instanace并且如果该表单有datetimepicker

控件那么我可以使用Text属性


frm.dtpDOB.Text


提前致谢。

解决方案

Questio n 3.


当用户不想设置任何日期并且控件是

datetimepicker时,我们该怎么办?在这种情况下如何设置空值,因为如果我们使用

datetimepicker控件,我们需要选择日期。


" patang"写道:

问题1
我有两种形式,比如Form1和Form2。 Form2上有datetimepicker控件
。在Form2的加载事件中,我已将
datetimepicker控件的默认值设置为NOW。因此,当我打开表单时,
默认值设置为今天的日期。现在我有时也会从Form1中调用Form2。好的,现在这是我的问题。实际上当我从Form1中调用Form2时,我想将datetimepicker控件的值设置为
else。我编写了以下代码来从form1调用form2并设置datetimepicker控件的
值:

Dim frm As Form2
frm = New Form2
frm.dtbDOB。 value =" 1/1 / 2005"
frm.showdialog()

我知道这种情况正在发生,因为当我从form1调用form2时,即使
我正在设置dtbDOB控件的值,但它被Load事件中设置的值
覆盖。

我该怎么办?

问题2
什么是DateTimePicker控件的Text属性的用途?

问题3.
为什么我在属性窗口中看不到Text属性,无论如何
当我创建一个instanace一个表单,如果那个表单有datetimepicker
控件,那么我可以将Text属性

frm.dtpDOB.Text

提前致谢。





" patang" < PA **** @ discussions.microsoft.com> schreef in bericht

新闻:E3 ********************************** @ microsof t.com ...

问题1
我有两种形式,比如Form1和Form2。 Form2上有datetimepicker控件
。在Form2的加载事件中,我已将
datetimepicker控件的默认值设置为NOW。因此,当我打开表单时,
默认值设置为今天的日期。现在我有时也会从Form1中调用Form2。好的,现在这是我的问题。实际上当我从Form1中调用Form2时,我想将datetimepicker控件的值设置为
。我编写了以下代码来从form1调用form2并将
设置为datetimepicker控件的值:

Dim frm As Form2
frm = New Form2
frm.dtbDOB。 value =" 1/1 / 2005"
frm.showdialog()

我知道这种情况正在发生,因为当我从form1调用form2时,即使是
虽然我正在设置dtbDOB控件的值但它被Load事件中设置的
值覆盖。

我该怎么办?

问题2
什么是DateTimePicker控件的Text属性的用途?

问题3.
为什么我在属性窗口中看不到Text属性,无论如何
当我创建一个instanace一个表单,如果那个表单有datetimepicker
控件,那么我可以将Text属性

frm.dtpDOB.Text

提前致谢。



回答你的第一个问题:

切换位置

frm.showdialog()

frm.dtbDO B.value =" 1/1 / 2005"


回答问题2:

尝试:

MsgBox( dtbDOB.Text)


回答问题3,在datetimepicker控件中总有一个

的日期,你不能把它变成空的我知道吗。


彼得


" patang" < PA **** @ discussions.microsoft.com> schreef in bericht

新闻:E3 ********************************** @ microsof t.com ...

问题1
我有两种形式,比如Form1和Form2。 Form2上有datetimepicker控件
。在Form2的加载事件中,我已将
datetimepicker控件的默认值设置为NOW。因此,当我打开表单时,
默认值设置为今天的日期。现在我有时也会从Form1中调用Form2。好的,现在这是我的问题。实际上当我从Form1中调用Form2时,我想将datetimepicker控件的值设置为
。我编写了以下代码来从form1调用form2并将
设置为datetimepicker控件的值:

Dim frm As Form2
frm = New Form2
frm.dtbDOB。 value =" 1/1 / 2005"
frm.showdialog()

我知道这种情况正在发生,因为当我从form1调用form2时,即使是
虽然我正在设置dtbDOB控件的值但它被Load事件中设置的
值覆盖。

我该怎么办?

问题2
什么是DateTimePicker控件的Text属性的用途?

问题3.
为什么我在属性窗口中看不到Text属性,无论如何
当我创建一个instanace一个表单,如果那个表单有datetimepicker
控件,那么我可以将Text属性

frm.dtpDOB.Text

提前致谢。



Question 1
I have two forms, let say Form1 and Form2. There is datetimepicker control
on Form2. In the Load Event of Form2 I have set the default value of
datetimepicker control to NOW. So as expected when I open the form the
default value is set to today''s date. Now I sometimes also call Form2 from
Form1. Ok now here is my problem. Actually when I call Form2 from within
Form1 I want to set the set the value of datetimepicker control to something
else. I have written following code to call form2 from form1 and setting the
value of datetimepicker control:

Dim frm As Form2
frm = New Form2
frm.dtbDOB.value = "1 / 1 / 2005"
frm.showdialog()

I know this is happeneing because when I call form2 from form1, even though
I am setting the value of dtbDOB control but it is overwritten by the value
set in Load Event.

What should I do ?

Question 2
What is the purpose of Text property of DateTimePicker Control ?

Question 3.
How come I don''t see the Text property in the properties window, however
when I create an instanace of an form and if that form has datetimepicker
control then I can the Text property

frm.dtpDOB.Text

Thanks in advance.

解决方案

Question 3.

What do we do when the user don''t want to set any date and the control is
datetimepicker. How do you set null value in this case because if we use
datetimepicker control we are requried to choose the date.

"patang" wrote:

Question 1
I have two forms, let say Form1 and Form2. There is datetimepicker control
on Form2. In the Load Event of Form2 I have set the default value of
datetimepicker control to NOW. So as expected when I open the form the
default value is set to today''s date. Now I sometimes also call Form2 from
Form1. Ok now here is my problem. Actually when I call Form2 from within
Form1 I want to set the set the value of datetimepicker control to something
else. I have written following code to call form2 from form1 and setting the
value of datetimepicker control:

Dim frm As Form2
frm = New Form2
frm.dtbDOB.value = "1 / 1 / 2005"
frm.showdialog()

I know this is happeneing because when I call form2 from form1, even though
I am setting the value of dtbDOB control but it is overwritten by the value
set in Load Event.

What should I do ?

Question 2
What is the purpose of Text property of DateTimePicker Control ?

Question 3.
How come I don''t see the Text property in the properties window, however
when I create an instanace of an form and if that form has datetimepicker
control then I can the Text property

frm.dtpDOB.Text

Thanks in advance.




"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:E3**********************************@microsof t.com...

Question 1
I have two forms, let say Form1 and Form2. There is datetimepicker control
on Form2. In the Load Event of Form2 I have set the default value of
datetimepicker control to NOW. So as expected when I open the form the
default value is set to today''s date. Now I sometimes also call Form2 from
Form1. Ok now here is my problem. Actually when I call Form2 from within
Form1 I want to set the set the value of datetimepicker control to something else. I have written following code to call form2 from form1 and setting the value of datetimepicker control:

Dim frm As Form2
frm = New Form2
frm.dtbDOB.value = "1 / 1 / 2005"
frm.showdialog()

I know this is happeneing because when I call form2 from form1, even though I am setting the value of dtbDOB control but it is overwritten by the value set in Load Event.

What should I do ?

Question 2
What is the purpose of Text property of DateTimePicker Control ?

Question 3.
How come I don''t see the Text property in the properties window, however
when I create an instanace of an form and if that form has datetimepicker
control then I can the Text property

frm.dtpDOB.Text

Thanks in advance.



To answer your first question:
switch places

frm.showdialog()
frm.dtbDOB.value = "1 / 1 / 2005"

to answer question number 2:
try:
MsgBox(dtbDOB.Text)

to answer question number 3, in a datetimepicker control there always is a
date, you can''t make it empty as far is I know.

hth Peter

"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:E3**********************************@microsof t.com...

Question 1
I have two forms, let say Form1 and Form2. There is datetimepicker control
on Form2. In the Load Event of Form2 I have set the default value of
datetimepicker control to NOW. So as expected when I open the form the
default value is set to today''s date. Now I sometimes also call Form2 from
Form1. Ok now here is my problem. Actually when I call Form2 from within
Form1 I want to set the set the value of datetimepicker control to something else. I have written following code to call form2 from form1 and setting the value of datetimepicker control:

Dim frm As Form2
frm = New Form2
frm.dtbDOB.value = "1 / 1 / 2005"
frm.showdialog()

I know this is happeneing because when I call form2 from form1, even though I am setting the value of dtbDOB control but it is overwritten by the value set in Load Event.

What should I do ?

Question 2
What is the purpose of Text property of DateTimePicker Control ?

Question 3.
How come I don''t see the Text property in the properties window, however
when I create an instanace of an form and if that form has datetimepicker
control then I can the Text property

frm.dtpDOB.Text

Thanks in advance.



这篇关于2个简单的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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