我从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的状态 以便加载的时候调用
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的状态 以便加载的时候调用
CallByName Check1, "", VbLet, 1
Dim str() As String str = Split("Check1=1", "=")
For Each ctl In Me.Controls
If TypeOf ctl Is CheckBox Then
If ctl.Name = str(0) Then
ctl = str(1)
End If
End If
Next
' 新建标准 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