pko/c Δημοσιεύτηκε Δεκέμβριος 16, 2004 #1 Κοινοποίηση Δημοσιεύτηκε Δεκέμβριος 16, 2004 Πως μπορω να διαβασω και να γραψω δυο σειριακα αρχεια μεσω Visual Basic; Link to comment Share on other sites More sharing options...
gleon Δεκέμβριος 16, 2004 #2 Κοινοποίηση Δεκέμβριος 16, 2004 Public Function GetFileContents(ByVal FullPath As String, _ Optional ByRef ErrInfo As String = "") As String Dim strContents As String Dim objReader As StreamReader Try objReader = New StreamReader(FullPath) strContents = objReader.ReadToEnd() objReader.Close() Return strContents Catch Ex As Exception ErrInfo = Ex.Message End Try End Function Public Function SaveTextToFile(ByVal strData As String, _ ByVal FullPath As String, _ Optional ByVal ErrInfo As String = "") As Boolean Dim Contents As String Dim bAns As Boolean = False Dim objReader As StreamWriter Try objReader = New StreamWriter(FullPath) objReader.Write(strData) objReader.Close() bAns = True Catch Ex As Exception ErrInfo = Ex.Message End Try Return bAns End Functionπαραδειγμα χρησης sContents = GetFileContents("C:\test.txt", sErr) If sErr = "" Then Debug.WriteLine("File Contents: " & sContents) 'Save to different file bAns = SaveTextToFile(sContents, "D:\Test.txt", sErr) If bAns Then Debug.WriteLine("File Saved!") Else Debug.WriteLine("Error Saving File: " & sErr) End If Else Debug.WriteLine("Error retrieving file: " & sErr) End If Link to comment Share on other sites More sharing options...
gleon Δεκέμβριος 16, 2004 #3 Κοινοποίηση Δεκέμβριος 16, 2004 Πάντως ένα γρήγορο search πριν ρωτήσουμε ο.τιδήποτε λείνει τις πρώτες μας απορείες.....μετά έχει ο θεός Link to comment Share on other sites More sharing options...
Kanonieris Δεκέμβριος 16, 2004 #4 Κοινοποίηση Δεκέμβριος 16, 2004 το "try" στον κώδικα τι είναι?? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.