TXT文本读取调用
我从TXT文本读取的字符串怎样在程序里当命令来用
Private Sub Form_Load()
Dim s As Object
Open App.Path & "\home.txt" For Input As #1
Line Input #1, i
Close #1
End Sub
我的i变量里是 Check1=1
我想在TXT保存我的check的状态 以便加载的时候调用
[解决办法]
- VB code
' 以下代码在 VB 6.0 中 IDE下、编译本机代码 exe 测试通过' 新建标准 EXE 工程' 添加 Check1, Check2, Check3' 添加 Command1, Text1' Set.txt 中的内容:'Check1=1'Check2=0'Check3=2'Command1=按钮文本'Text1=运行时改变控件属性!Option ExplicitPrivate Sub Command1_Click() '下面文件路径按你实际情况写 '请保证格式正确 Open "X:\Temp\Set.txt" For Input As #1 Dim strText$, arrParam$() While (Not EOF(1)) Line Input #1, strText arrParam = Split(strText, "=") If (InStr(1, arrParam(0), "Command") = 1) Then CallByName Controls(arrParam(0)), "Caption", VbLet, arrParam(1) Else If (InStr(1, arrParam(0), "Text") = 1) Then CallByName Controls(arrParam(0)), "Text", VbLet, arrParam(1) Else CallByName Controls(arrParam(0)), "Value", VbLet, arrParam(1) End If End If WendEnd Sub