打开输入VB时指定编码

Tho*_*res 4 encoding vba file

我正在尝试使用以下行在Excel中打开一个输入文件:

Open tmpNmFichier For Input Shared As #iFnum
Run Code Online (Sandbox Code Playgroud)

问题是我的文件有一些字符,如:"é","à"...当我解析文件时:

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
Run Code Online (Sandbox Code Playgroud)

我的角色"é"......被改造成:"Ã"或"Ã......"

你知道我怎么能明确我的文件的编码或类似的东西吗?

Cyl*_*ian 6

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
Run Code Online (Sandbox Code Playgroud)

TristateUseDefault -2 Opens the file using the system default. 
TristateTrue -1 Opens the file as Unicode. 
TristateFalse  0 Opens the file as ASCII. 
Run Code Online (Sandbox Code Playgroud)