VB.NET:测试自定义控件 [英] VB.NET: testing a custom control

查看:83
本文介绍了VB.NET:测试自定义控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法获取计算日期间隔并将文本添加到标签中。我知道如果我得到总天数,测试程序中的代码就可以工作,所以问题在于控件的代码。当我打印Date1时,我得到上午12:00,但似乎无法让datetimepicker在计算中使用日期。


感谢您愿意提供帮助!


自定义控件的代码:

ReadOnly Property totdays()As Double

获取

totdays = DateDiff(DateInterval.Day,Date1,Date2)

结束获取

结束财产


ReadOnly属性startdate()As String

获取

Dim str As String

str ="开始日期:"

Lbl1.Text = str

结束获取

结束物业


ReadOnly Property enddate()As String

获取

Dim str As String

str ="结束日期:"

Lbl2.Text = str

结束获取

结束物业

结束班级


测试代码:


Private Sub BtnCalc_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理BtnCalc.Click

Dim totdays作为整数

lblCharge.Text = totdays * 50

Label1.Text = totdays

End Sub

End Class

I am having difficulties getting the date interval to calculate and to get the text added to the labels. I know the code in the test program works if I get the total days, so the problem is with the code for the control. When I print Date1 I get 12:00 AM but cannot seem to get the datetimepicker to use dates in the calculation.

Thanks for your willingness to help!


The code for the custom control:
ReadOnly Property totdays() As Double
Get
totdays = DateDiff(DateInterval.Day, Date1, Date2)
End Get
End Property

ReadOnly Property startdate() As String
Get
Dim str As String
str = "Start Date:"
Lbl1.Text = str
End Get
End Property

ReadOnly Property enddate() As String
Get
Dim str As String
str = "End Date:"
Lbl2.Text = str
End Get
End Property
End Class

the test code:

Private Sub BtnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalc.Click
Dim totdays As Integer
lblCharge.Text = totdays * 50
Label1.Text = totdays
End Sub
End Class

推荐答案


我无法获得计算日期间隔并将文本添加到标签中。我知道如果我得到总天数,测试程序中的代码就可以工作,所以问题在于控件的代码。当我打印Date1时,我得到上午12:00,但似乎无法让datetimepicker在计算中使用日期。


感谢您愿意提供帮助!


自定义控件的代码:

ReadOnly Property totdays()As Double

获取

totdays = DateDiff(DateInterval.Day,Date1,Date2)

结束获取

结束财产


ReadOnly属性startdate()As String

获取

Dim str As String

str ="开始日期:"

Lbl1.Text = str

结束获取

结束物业


ReadOnly Property enddate()As String

获取

Dim str As String

str ="结束日期:"

Lbl2.Text = str

结束获取

结束物业

结束班级


测试代码:


Private Sub BtnCalc_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理BtnCalc.Click

Dim totdays作为整数

lblCharge.Text = totdays * 50

Label1.Text = totdays

End Sub

End Class
I am having difficulties getting the date interval to calculate and to get the text added to the labels. I know the code in the test program works if I get the total days, so the problem is with the code for the control. When I print Date1 I get 12:00 AM but cannot seem to get the datetimepicker to use dates in the calculation.

Thanks for your willingness to help!


The code for the custom control:
ReadOnly Property totdays() As Double
Get
totdays = DateDiff(DateInterval.Day, Date1, Date2)
End Get
End Property

ReadOnly Property startdate() As String
Get
Dim str As String
str = "Start Date:"
Lbl1.Text = str
End Get
End Property

ReadOnly Property enddate() As String
Get
Dim str As String
str = "End Date:"
Lbl2.Text = str
End Get
End Property
End Class

the test code:

Private Sub BtnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalc.Click
Dim totdays As Integer
lblCharge.Text = totdays * 50
Label1.Text = totdays
End Sub
End Class



在测试代码中,totDays只是一个本地定义的整数变量,其值为零(默认情况下)。所以乘以50应该仍然给你零。这是你的意思吗?


至于自定义控件中的代码 - 这是VB.net吗?

In your test code, totDays is just a locally defined integer variable with zero value (by default). So multiplying it by 50 should still give you zero. Is this what you intended?

As for the code in the custom control - is this VB.net?



在测试代码中,totDays只是一个本地定义的整数变量,其值为零(默认情况下)。所以乘以50应该仍然给你零。这是你的意思吗?


至于自定义控件中的代码 - 是这个VB.net吗?
In your test code, totDays is just a locally defined integer variable with zero value (by default). So multiplying it by 50 should still give you zero. Is this what you intended?

As for the code in the custom control - is this VB.net?



我的意图是从自定义控件中取出总计,然后在测试程序中将它乘以50。我正在使用VB 2003进行此练习。


My intent is to take the totdays from the custom control and then multiply it by 50 in the test program. I am using VB 2003 for this exercise.



我的目的是从自定义控件中取出总计,然后将其乘以50测试程序。我正在使用VB 2003进行此练习。
My intent is to take the totdays from the custom control and then multiply it by 50 in the test program. I am using VB 2003 for this exercise.



Hm ......


我仍​​然认为旧的VB6,但我觉得应该有一个迹象你指的是控件的totdays属性。 controlname.totdays 的内容。


不要把它作为福音,但我可能会偏离轨道。

Hm...

I still think in terms of old VB6, but I feel that there should be an indication that you are referring to the totdays property of a control. Something along the lines of controlname.totdays.

Don''t take this as Gospel, though - I may be way off track.


这篇关于VB.NET:测试自定义控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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