我从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的状态 以便加载的时候调用

解决方案 »

  1.   

    CallByName( Check1, vbset, 1)
      

  2.   

    要是这样,你直接 保存/设置 check 的状态属性不就行了吗。
      

  3.   

    修改下
    CallByName Check1, "", VbLet, 1
      

  4.   

    我有很多CHECK选项 每人选项的内容都不同  所以想保存在TXT文本里 这样下次运行的时候就不用从新选择了
      

  5.   

        Dim ctl As Object
        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
      

  6.   

    ' 以下代码在 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
      

  7.   

    在麻烦一下 请问如果文本里面是Check数组能实现么? 拜托了