日期功能 [英] Date function

查看:69
本文介绍了日期功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一天的名字,例如''星期一'

如果你有

天,是否有一些功能可以返回一周的天数姓名或我应该写选择案例陈述?


如果当天是''星期一',那么结果应该是2.


谢谢你,

西蒙

I have the name of a day like for example ''Mon''
Is there some function which returns the number of a weekDay if you have the
day name or I should write the select case statements?

If the day is ''Mon'' then result should be 2.

Thank you,
Simon

推荐答案

西蒙,


我想我会这样做的。

\\\

Dim myfield As String =" Mon"

Dim mydays As String()= {" Sun,Mon,Tue,rest}

Dim i As Integer

for i = 0到mydays.Length - 1

如果mydays(i)= myfield那么

MessageBox.Show(" I did find"& i.ToString& _

"周日=&新日期()。DayOfWeek)

退出

结束如果

下一页

Dim myday As Integer = i + 1

////

我希望这有帮助吗?


Cor
Hi Simon,

I think I would do it like this.
\\\
Dim myfield As String = "Mon"
Dim mydays As String() = {"Sun", "Mon", "Tue", "rest"}
Dim i As Integer
For i = 0 To mydays.Length - 1
If mydays(i) = myfield Then
MessageBox.Show("I did find " & i.ToString & _
" while the day of week = " & New Date().DayOfWeek)
Exit For
End If
Next
Dim myday As Integer = i + 1
////
I hope this helps?

Cor
我有一天的名字,例如''星期一'
如果你有
的日期名称或者我应该编写选择案例陈述,是否有一些函数可以返回一周的日期?

如果那天是星期一,那么结果应为2。
I have the name of a day like for example ''Mon''
Is there some function which returns the number of a weekDay if you have the day name or I should write the select case statements?

If the day is ''Mon'' then result should be 2.



" simon" < SI ********* @ stud-moderna.si> schrieb
"simon" <si*********@stud-moderna.si> schrieb
我有一天的名字,例如''星期一'
如果你有一天的名字,或者有一些星期几的函数吗?我应该写一些精选案例陈述?

如果那天是星期一,那么结果应该是2。
I have the name of a day like for example ''Mon''
Is there some function which returns the number of a weekDay if you
have the day name or I should write the select case statements?

If the day is ''Mon'' then result should be 2.



我认为第7天是星期天...

我没有找到内置方法。以下代码应该有效。我假设

工作日的数字是1到7,一周的第一天是星期日。


Dim WeekdayNames As String()= {_

Nothing,Sun,Mon,Tue,Wed,Thu,Fri,Sat等。 _

}


MsgBox(DirectCast(WeekdayNames,IList).IndexOf(" Mon"))

如果你有的话需要用数组获取索引,你也可以将
声明为IList ...


Dim WeekdayNames为IList = New String() {_

Nothing,Sun,Mon,Tue,Wed,Thu,Fri,Sat等。 _

}


....每次都要避免输入类型 - 或者将大量的代码放入

程序或课程。

-

Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


I thought the 7th day is Sunday...
I didn''t find a built-in method. The following code should work. I assume
the weekday number is 1 to 7 and the first day of the week is Sunday.

Dim WeekdayNames As String() = { _
Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _
}

MsgBox(DirectCast(WeekdayNames, IList).IndexOf("Mon"))
If all you need to do with the array is getting the index, you can also
declare it as IList ...

Dim WeekdayNames As IList = New String() { _
Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _
}

.... to avoid type casting each time - or put this huge amount of code in a
procedure or a class.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


嗨Armin,

好​​的一个(array.indexof)和那个没什么的我也在考虑,

开始索引。


:-)


Cor
Hi Armin,

Nice one (array.indexof) and about that "nothing" I was thinking also, to
start the index on one.

:-)

Cor
Dim WeekdayNames As String()= {_
Nothing,Sun,Mon,Tue,Wed,Thu, 星期五,星期六。 _
}

MsgBox(DirectCast(WeekdayNames,IList).IndexOf(" Mon))

如果您需要对阵列进行所有操作索引,你也可以将它声明为IList ...

Dim WeekdayNames为IList = New String(){_
Nothing,Sun,Mon ;,Tue,Wed,Thu,Fri,Sat等。 _
}
Dim WeekdayNames As String() = { _
Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _
}

MsgBox(DirectCast(WeekdayNames, IList).IndexOf("Mon"))
If all you need to do with the array is getting the index, you can also
declare it as IList ...

Dim WeekdayNames As IList = New String() { _
Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _
}



这篇关于日期功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆