VB通过INI配置文件中的路径读取TXT内容到Text1.Text
spama.ini配置文件内容[ptom]
ath=d:\sd
VB通过spama.ini配置文件中的路径读d:\sd\ss.txt的内容到Text1.Text。(ss.txt不在配置文件的路径中显示。)
求代码。
自己偿试写了代码,经调试出现错误:
路径/文件访问错误
调试
open strvalue & "\ss.txt" for input as #1
这里路径无法访问。求解!谢谢!
Private Declare Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Sub Command1_Click()
strValue = String(FileLen( "spama.ini"), 0)
n=GetPrivateProfileString("ptom","ath", "", strValue, Len(strValue) - 1, "spama.ini")
If n > 1 Then
strValue = StrConv(LeftB(StrConv(strValue, vbFromUnicode), n), vbUnicode)
End If
open strvalue & "\ss.txt" for input as #1
Text1.Text = Input$(LOF(1), #1)
Close #1
End Sub
[此贴子已经被作者于2017-7-5 00:02编辑过]