Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 797
  • Last Modified:

VB.net code to check time

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
xzay1967
Asked:
xzay1967
1 Solution
 
CodeCruiserCommented:
0
 
käµfm³d 👽Commented:
...or:

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

Open in new window

0
 
xzay1967Author Commented:
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
 
käµfm³d 👽Commented:
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
 
Martin LissRetired ProgrammerCommented:
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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now