Solved

VB.net code to check time

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

929 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

12 Experts available now in Live!

Get 1:1 Help Now