Solved

VB.net code to check time

Posted on 2014-04-10
6
676 Views
Last Modified: 2014-05-12
Hi all I am trying to write a script in vb.net needs to send an email but only between a certain time frame. Something to effect of
if x is = y and y is = w and time is between 5pm and 11pm then send the email. Everything works so far, I just need the piece for the time range.
0
Comment
Question by:xzay1967
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39991701
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39991749
...or:

... (Now.Hour >= 17 AndAlso Now.Hour <= 23) Then

Open in new window

0
 

Author Comment

by:xzay1967
ID: 39992016
hmm,@kaufmed, so if I used your suggestion, would I apply it as:
if x=y and y=w and if (Now.Hour >= 17 AndAlso Now.Hour <= 23) Then "send email"? Do I need to declare anything first?
@CodeCruiser not ignoring your suggestion, just gonna try the simpler option.
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39992042
Logically speaking, yes. In specific code, though, you've got a syntax issue.

i.e.

If x = y AndAlso y = w AndAlso Now.Hour >= 17 AndAlso Now.Hour <= 23 Then
    "send email"
End If

Open in new window


You had an extra "If" in yours.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40058458
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now