2012-06-12 56 views
2

我試圖在Excel中打開一個文件輸入與此線路編碼:指定當打開輸入VB

Open tmpNmFichier For Input Shared As #iFnum 

的問題是,我的文件有像一些文字:「E」,「à 「......當我解析與文件:

Dim s As String 

Line Input #iFnum, s 
If Len(s) > 0 Then 
    v = Split(s, tmpSeparateur) 
Else 
    ReDim v(-1 To -1) 
End If 

我的角色‘é’...轉化中:‘A’或‘......’

你有任何想法如何我可以明確的編碼我的文件或類似的東西?

回答

4

使用FileSystemObject代替

Public Function GetContent(fpath$) As String 
    'REFERENCES: 
    'Microsoft Scripting Runtime // Scripting.FileSystemObject 
    Dim fso As New Scripting.FileSystemObject, content$ 
    If fso.FileExists(fpath) Then 
     content = fso.OpenTextFile(fpath, ForReading, False, TristateTrue).ReadAll() 
     GetContent = content 
    Else 
     MsgBox "Invalid file path." 
     GetContent = vbNullChar 
    End If 
End Function 

TristateUseDefault -2 Opens the file using the system default. 
TristateTrue -1 Opens the file as Unicode. 
TristateFalse 0 Opens the file as ASCII. 
+0

有趣。 CHR – Fionnuala

相關問題