Datetime 使用vb.net为没有分隔符的日期添加分隔符
我有一个格式为“13092017”的日期,我必须添加分隔符“-”,并使用vb.net显示在文本框中Datetime 使用vb.net为没有分隔符的日期添加分隔符,datetime,vb.net-2010,Datetime,Vb.net 2010,我有一个格式为“13092017”的日期,我必须添加分隔符“-”,并使用vb.net显示在文本框中 Private Sub SettlementDetailUpload_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try Dim s1 As String = "13092017" Catch ex As Exception End Try End Sub 你可以这样做
Private Sub SettlementDetailUpload_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim s1 As String = "13092017"
Catch ex As Exception
End Try
End Sub
你可以这样做:
Private Sub SettlementDetailUpload_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim s1 As String = "13092017"
Dim DayStr, MonthStr, YearStr, FinalDate As String
DayStr = s1.Remove(2)
MonthStr = s1.Substring(2, 2) 'The first '2' is where to start cutting and the 2nd '2' is how much you need to cutm which is 2 in this case.
YearStr = s1.Substring(4)
FinalDate = DayStr & "-" & MonthStr & "-" & YearStr
Msgbox(FinalDate)
Catch : End Try
End Sub
希望它有用:)您可以这样做:
Private Sub SettlementDetailUpload_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim s1 As String = "13092017"
Dim DayStr, MonthStr, YearStr, FinalDate As String
DayStr = s1.Remove(2)
MonthStr = s1.Substring(2, 2) 'The first '2' is where to start cutting and the 2nd '2' is how much you need to cutm which is 2 in this case.
YearStr = s1.Substring(4)
FinalDate = DayStr & "-" & MonthStr & "-" & YearStr
Msgbox(FinalDate)
Catch : End Try
End Sub
希望它会有用:)那么您想要输出:
13-09-2017
?是的,任何分隔符都可以。那么您想要输出:13-09-2017
?是的,任何分隔符都可以