0
在此代碼中,將數據保存在文件中,並且其中的Examdate
,Examtime
和DOB
保存爲例如:03:15 PM,我希望它們爲1515 (也有秒)。我不知道該怎麼辦?如何在文件中將日期和時間保存爲yyyymmdd&hhmmss
Private Sub HL_Click(sender As Object, e As EventArgs) Handles HL.Click
Dim file As System.IO.StreamWriter
Dim fileDateTime As String = DateTime.Now.ToString("yyyyMMdd") & "_" & DateTime.Now.ToString("HHmmss")
file = My.Computer.FileSystem.OpenTextFileWriter(fileDateTime, True)
file.WriteLine("MSH|^~\&|||||" & TxtExamtime.Text & "||ORM^O01||P|2.3.1")
file.WriteLine("PID|||" & TxtId.Text & "||" & TxtFamilyname.Text & "^" & TxtGivenname.Text & "||" & TxtDob.Text & "||" & TxtGender.Text & "|||" & TxtStreet.Text & " " & TxtHouse.Text & "^^" & TxtCity.Text & "^^" & TxtPostcode.Text)
file.WriteLine("PV1||O|||||||||||||||||" & TxtId.Text & "|||||||||||||||||||||||||" & TxtExamdate.Text)
file.WriteLine("ORC|NW|" & TxtId.Text & "|||||^^^" & TxtExamdate.Text & "||" & TxtExamdate.Text)
file.WriteLine("OBR||" & TxtExamdate.Text & TxtExamdate.Text & "||CT|||" & TxtExamtime.Text & "|" & TxtExamtime.Text)
file.WriteLine()
file.Close()
MessageBox.Show("Textsaved to " & fileDateTime)
End Sub
你有你的文本框爲DateTime轉換,如果你想創業做任何操作。 –