本文介绍了如何使用指定的时间来决定运行的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助的是(if语句)如何根据指定的工作日时间确定使用哪种方法(运行进程)。日期是无关紧要的。

如何使用指定的时间来决定使用的方法?

我不需要过程甚至方法的帮助。我需要帮助的是if语句来确定使用哪种方法。



两种方法 AllDocuments GetDocsInLast60Minutes 将根据指定的时间使用。



要求

方法AllDocuments

如果时间是早上8点到9点,则使用AllDocuments方法

如果时间是上午11点 - 上午11:05使用AllDocuments方法

如果时间是1 PM - 1:05 PM使用AllDocuments方法

如果时间是下午3点 - 下午3:05使用AllDocuments方法

如果时间是下午5点 - 5点: 05 PM AllDocuments方法使用





方法GetDocsInLast60Minutes

如果时间是上午9点到下午5点GetDocsInLast60Minutes使用方法



我尝试过:



我不是确定如何处理if语句

What I need help with is (if statements) how to determine which method to use (to run a process) based on specified weekday time. Dates are irrelevant.
How do I use specified time to decide the method to use?
I do not need help with the process or even the methods. All I need help with is if statements to determine which method to use.

The two methods AllDocuments and GetDocsInLast60Minutes will be used based on specified times.

Requirements
Method AllDocuments
If the time is 8 AM to 9 AM AllDocuments method is used
If the time is 11 AM - 11:05 AM AllDocuments method is used
If the time is 1 PM - 1:05 PM AllDocuments method is used
If the time is 3 PM - 3:05 PM AllDocuments method is used
If the time is 5 PM - 5:05 PM AllDocuments method is used


Method GetDocsInLast60Minutes
If the time is 9 AM to 5 PM GetDocsInLast60Minutes method is used

What I have tried:

I am not sure how to go about the if statements

If (time is 8AM to 9AM) Then
Use GetDocsInLast60Minutes 

If (time is between 11 AM and 11:05 AM ) Then
Use AllDocuments
'etc

推荐答案


Imports System
				
Public Module Module1
	Public Sub Main()
		
		Dim now As Date = Date.Now
		
		Dim hour As Integer = now.Hour
		Dim minute As Integer = now.Minute
		
		Console.WriteLine(hour)
		Console.WriteLine(minute)

		If hour = 13 And minute <= 5  Then
			Console.WriteLine("Run method A")
        Else
            Console.WriteLine("Run method B")
        End If
		
	End Sub
End Module

如果您寻求进一步操纵日期时间,请参阅Richard的链接。学习编码的一种方法是参考文档并试验各种方法。

Refer to the link by Richard if you seek further manipulation of date time. One way to learn coding is to refer to the document and experiment with the various methods.


这篇关于如何使用指定的时间来决定运行的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 13:04