vb net中怎么样将字符串类型转换成日期型
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vb net中怎么样将字符串类型转换成日期型相关的知识,希望对你有一定的参考价值。
参考技术A 给你一个例子,里边包含了几种不同格式转换成标准的日期时间格式;Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
' 01/09/2001 00:00:00
Dim MyDateTime1 As DateTime = DateTime.Parse("Sep 2001")
' 05/09/2001 14:15:33
Dim MyDateTime2 As DateTime = DateTime.Parse("Wed 5 September 2001 14:15:33")
' 01/09/2005 00:00:00
Dim MyDateTime3 As DateTime = DateTime.Parse("5,9,01")
' 09/05/2001 14:15:33
Dim MyDateTime4 As DateTime = DateTime.Parse("5/9/2001 14:15:33")
' 当前系统日期 14:15:00
Dim MyDateTime5 As DateTime = DateTime.Parse("2:15 PM")
Dim MyInfo As String = MyDateTime1.ToString()
MyInfo += vbCrLf + MyDateTime2.ToString()
MyInfo += vbCrLf + MyDateTime3.ToString()
MyInfo += vbCrLf + MyDateTime4.ToString()
MyInfo += vbCrLf + MyDateTime5.ToString()
MessageBox.Show(MyInfo, "信息提示", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "信息提示", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub
End Class本回答被提问者和网友采纳
以上是关于vb net中怎么样将字符串类型转换成日期型的主要内容,如果未能解决你的问题,请参考以下文章