Solved

VB.net code to check time

Posted on 2014-04-10
6
735 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 75

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 75

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 46

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…

770 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