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
10 1644
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
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?
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?
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.
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...
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.
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.
Tried that - still did not work.
Tried that - still did not work.
What did happen?
What did happen?
I got a message that what I entered had not been declared. I entered thwe name of the control.totdays, or daterange.totdays. I put this in the click event for the button in the test program.
I got a message that what I entered had not been declared. I entered thwe name of the control.totdays, or daterange.totdays. I put this in the click event for the button in the test program.
Generally, I'd expect that you would have to have added an instance of the custom control to the form. You should then be able to access its properties. It's just like adding any other control, such as a label or button. Have you placed the custom control on the form?
However, keep in mind that I'm still talking from a VB6 perspective, so may be out of date.
Generally, I'd expect that you would have to have added an instance of the custom control to the form. You should then be able to access its properties. It's just like adding any other control, such as a label or button. Have you placed the custom control on the form?
However, keep in mind that I'm still talking from a VB6 perspective, so may be out of date.
Yes,, I have the control on the form and have referenced the test project to the control.
Yes,, I have the control on the form and have referenced the test project to the control.
Can you paste in the actual line of code producing the error, and tell us the exact message it displays?
Can you paste in the actual line of code producing the error, and tell us the exact message it displays?
I have now got the text names for the labels to be filled in by the control when the test program is run. The problem now seems to be with the code I have for the total number of days between the datetimepicker1 (date1) and datetimepicker2 (date2). In an attempt to find the problem, I selected date1 to print and got a value of 1200 AM so apparently need to do a conversion somewhere to get just the date. The code is below:
Public Property tdays() As Integer
Get
tdays = DateDiff(DateInterval.Day, Date1, Date2)
End Get
Set(ByVal value As Integer)
tdays = value
End Set
End Property
Thanks for your continued help!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben Taylor |
last post by:
Hi
I am trying to build, more for a learning project than anything, an ASP.NET
web application in C# that will run on my local machine, which has now
successully got IIS installed on it (XP pro)....
|
by: RA |
last post by:
Hi
I have created a Windows installer project from the .net vs. When I add
custom actions for the Uninstall event how can I tell it in what sequence to
launch the custome action? Whats happening...
|
by: MarkD |
last post by:
I have an ASP.NET (VB.NET) application that calls all VB6 COM DLL via
Interop. The DLL uses functionality contained in a Custom OCX Control
(Also VB6) that in turn contains a standard TreeView...
|
by: Metallicraft |
last post by:
I have a vb6 application. On the main form is a picture
box with one or two images and several pieces of text
displayed in it. These are created on the fly using gdi32
routines that are all in a...
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of...
|
by: shamirza |
last post by:
· When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000,
outlining the .NET 'vision'. The July 2000 PDC had a number of sessions
on .NET technology, and...
|
by: shamirza |
last post by:
· What is view state and use of it?
The current property settings of an ASP.NET page and those of any
ASP.NET server controls contained within the page. ASP.NET can detect
when a form is requested...
|
by: VB |
last post by:
iTechArt Group - Custom Software Development and Offshore outsourcing
Company
http://www.itechart.com/
Offshore custom software development company iTechArt - Web site and
Content Management...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |