发布网友 发布时间:2022-05-04 12:07
共3个回答
热心网友 时间:2022-06-21 17:11
txt文件中不要用vb语句,这样处理会简单的多。例如1.txt 文件中是这些内容:
Private Sub Form_Load()
Dim s As String, c As String, ctl As Control
Open App.Path & "\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, s
If Left(s, 1) = "[" Then
c = Mid(s, 2, InStrRev(s, "]") - 2)
Set ctl = Nothing
For Each ctl In Me.Controls
If ctl.Name = c Then
Exit For
End If
Next
Else
If Trim(s) <> "" And Not (ctl Is Nothing) Then
If TypeOf ctl Is TextBox Then
ctl.Text = s
ElseIf TypeOf ctl Is ComboBox Or TypeOf ctl Is ListBox Then
ctl.AddItem s
ElseIf TypeOf ctl Is CommandButton Or TypeOf ctl Is Label Then
ctl.Caption = s
End If
End If
End If
Loop
Close #1
End Sub
热心网友 时间:2022-06-21 17:11
热心网友 时间:2022-06-21 17:12
'执行代码需要调用API: