?
Solved

Error by Day(Now) in a Windows application

Posted on 2012-08-29
11
Medium Priority
?
362 Views
Last Modified: 2012-08-30
In a web application I can use Year(Now), Month(Now), and Day(Now) just as I would expect.

In a Windows application I can use Year(Now) and Month(Now) but NOT Day(Now) and this is certainly not what I would expect. When I use it, I get the error:

Error      1      'Day' is a type and cannot be used as an expression.      C:\1. Applications NZ-QM\Windows\SAP Recurring Tool Aid\SAP Recurring Tool Aid\Form1.vb      43      16      SAP Recurring Tool Aid

Can you tell me:

1/ Why can I not use Day(Now)?

2/ How can I then find the day number in a month?
0
Comment
Question by:neesgaard
10 Comments
 
LVL 18

Accepted Solution

by:
Cluskitt earned 1000 total points
ID: 38345022
Add this to your form:
Imports Microsoft.VisualBasic.DateAndTime
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 1000 total points
ID: 38345032
Or use

Now.Today.Day
0
 

Author Comment

by:neesgaard
ID: 38345092
I tried to split points but did not succeed - sorry for this.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 38345093
for your second question, you can use DaysInMonth as shown in http://msdn.microsoft.com/en-us/library/system.datetime.daysinmonth.aspx
0
 

Author Comment

by:neesgaard
ID: 38345100
1/ First suggestion works fine!

2/ Second suggestion should be Date.Today.Day.
0
 
LVL 18

Expert Comment

by:Cluskitt
ID: 38345243
You can request attention and ask for the points to be reassigned, or for the question to be open and then select multiple answers.
0
 

Author Comment

by:neesgaard
ID: 38345355
Is there a waiting time for the question to be opened?
0
 
LVL 18

Expert Comment

by:Cluskitt
ID: 38345368
You have to wait till a moderator sees it, but you'll be notified when it is.
0
 

Author Comment

by:neesgaard
ID: 38349181
Thank you!
0
 

Author Comment

by:neesgaard
ID: 38349190
Split is now completed!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question