VB.NET新增功能。在下面的代碼當我編譯它時,我得到一個錯誤,當我檢查選擇 Radiobutton並瀏覽文件夾和clikc GENERATE HL7消息我得到一個錯誤爲「錯誤:表達式是一個值,因此不能「當我檢查默認 Radiobutton它的作品就像一個魅力。但是,當我檢查選擇 Radiobutton我得到的錯誤。我不知道我的代碼有什麼問題。你可以找到我在下面的URL設計:[URL = http://s1065.photobucket.com/user/Izaz_Ahmed/media/Capture_zpst4jjgvxb.jpg.html]如何使用FolderBrowsedialog將文本框數據保存到文件
Private Sub HL_Click(sender As Object, e As EventArgs) Handles HL.Click
If vld(TxtProcode) = False Then
Exit Sub
End If
Dim file As System.IO.StreamWriter
Dim folderBrowser As New FolderBrowserDialog
Dim fileDateTime As String = DateTime.Now.ToString("yyyyMMdd") & DateTime.Now.ToString("HHmmss") & ".HL7"
Dim ts As String = DateTime.Now.ToString("yyyyMMdd") & DateTime.Now.ToString("HHmmss")
'file = My.Computer.FileSystem.OpenTextFileWriter("C:\pdata\New folder\" & fileDateTime, True)
folderBrowser.ShowNewFolderButton = True
If RadioBtndefault.Checked Then
TxtDob.Format = DateTimePickerFormat.Custom
TxtDob.CustomFormat = "yyyyMMdd"
TxtExamtime.Format = DateTimePickerFormat.Custom
TxtExamtime.CustomFormat = "hhMMss"
TxtExamdate.Format = DateTimePickerFormat.Custom
TxtExamdate.CustomFormat = "yyyyMMdd"
file = My.Computer.FileSystem.OpenTextFileWriter("C:\pdata\New folder\" & fileDateTime, True)
file.WriteLine("MSH|^~\&|||||" & TxtExamdate.Text & "" & 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 & "|||||||||||||||||||||||||" & ts)
file.WriteLine("ORC|NW|" & ts & "|||||^^^S||" & TxtExamdate.Text)
file.WriteLine("OBR||" & ts & "^" & ts & "||" & TxtProcode.Text & "|||" & TxtExamdate.Text & "" & TxtExamtime.Text & "|" & TxtExamdate.Text & "" & TxtExamtime.Text)
file.WriteLine()
file.Close()
End If
If RadioBtnselect.Checked Then
If folderBrowser.ShowDialog() = DialogResult.OK Then
file.WriteLine = folderBrowser.SelectedPath
file.WriteLine("MSH|^~\&|||||" & TxtExamdate.Text & "" & 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 & "|||||||||||||||||||||||||" & ts)
file.WriteLine("ORC|NW|" & ts & "|||||^^^S||" & TxtExamdate.Text)
file.WriteLine("OBR||" & ts & "^" & ts & "||" & TxtProcode.Text & "|||" & TxtExamdate.Text & "" & TxtExamtime.Text & "|" & TxtExamdate.Text & "" & TxtExamtime.Text)
file.WriteLine()
file.Close()
Dim root As Environment.SpecialFolder = folderBrowser.RootFolder
End If
End If
End Class
結合SelectedPath當實現這個得到一個錯誤,如「**錯誤:重載決策失敗,因爲沒有可訪問的‘OpenTextFileWriter’接受此數目的參數。 **「 – Izaz
右鍵忘記第二個參數,它可以是布爾值True將文本追加到現有文件或布爾False以用新數據覆蓋現有文件。根據你的第一個模塊,我用True來追加 – Steve