Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果不是vb.net,程序将知道时间跨度_Vb.net_If Statement - Fatal编程技术网

如果不是vb.net,程序将知道时间跨度

如果不是vb.net,程序将知道时间跨度,vb.net,if-statement,Vb.net,If Statement,我不知道它怎么叫这就是为什么我叫它时间跨度。 我还不知道如何编码,但这就是我想做的 Dim sy as String If (June 2015) to (March 2016) Then sy = "2015-2016" End if 我知道这很简单,但我不知道如何编写2015年6月至2016年的代码 提前谢谢你的帮助 编辑: 现在我要讲这个密码了 我过去经常这样做 Dim value as DateTime = New DateTime(2017, 4, 1) Dim value1

我不知道它怎么叫这就是为什么我叫它时间跨度。 我还不知道如何编码,但这就是我想做的

Dim sy as String

If (June 2015) to (March 2016) Then

sy = "2015-2016"

End if
我知道这很简单,但我不知道如何编写2015年6月至2016年的代码

提前谢谢你的帮助

编辑: 现在我要讲这个密码了

我过去经常这样做

Dim value as DateTime = New DateTime(2017, 4, 1)
Dim value1 as DateTime = New DateTime(2018, 4, 1)

    Dim sy as String
    If my.computer.clock.localtime <= value then
    sy = "2016-2017"
    ElseIf my.computer.clock.localtime <= value1 then
    sy = "2017-2018"
    Else
    msgbox("Check your current date")
    End if
Dim值为DateTime=newdatetime(2017,4,1)
作为日期时间的Dim值1=新日期时间(2018,4,1)
朦胧如弦

如果my.computer.clock.localtime,那么我将使用4个文本框作为变量提供所需的数据。2年和2个月。此外,你还需要考虑一年中还剩多少蛾子,并加上下一年的月数。如果你跨越一年以上,你也必须考虑到这一点。好的,下面是按钮事件中没有错误检查的代码段:

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    Dim firstÝear As Integer = CInt(TextBox3.Text)
    Dim secondYear As Integer = CInt(TextBox4.Text)
    Dim firstmonthnumber As Integer = CInt(TextBox5.Text) 'months number in first year
    Dim secondmonthnumber As Integer = CInt(TextBox6.Text)
    Dim d1 As DateTime = New DateTime(firstÝear, firstmonthnumber, 1)
    Debug.Print(d1.ToString)
    Dim d2 As DateTime = New DateTime(secondYear, secondmonthnumber, 1)
    Debug.Print(d2.ToString)
    Dim M As Integer = Math.Abs((d1.Year - d2.Year)) - 1
    Debug.Print(M.ToString)
    Dim myYear As Integer = 12 - firstmonthnumber 'month left to the end of first year
    Dim months As Integer = ((M * 12) + Math.Abs((d1.Month - d2.Month))) + myYear
    Debug.Print(months.ToString)
End Sub

使用两个
Date
-变量或将它们放入具有
StartTime
EndTime
属性的新类中。。。。或者使用这个库:你能给我一个示例代码吗?我还不知道如何打开这个选项
sy
最终将成为
“1”
。我忘了在2015-2016年写“对不起”