Option Explicit
Private Sub btnExport_Click()
Dim strText As String
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is Label Then
strText = strText & "lbl;" & ctl.Name & " " & ctl.Caption & vbNewLine
ElseIf TypeOf ctl Is TextBox Then
strText = strText & "txt;" & ctl.Name & " " & ctl.Text & vbNewLine
End If
Next ctl
Open App.Path & "\tempdata.txt" For Output As #1
Print #1, strText
Close #1
End Sub
Private Sub btnImport_Click()
Dim strLine As String, pos%
Dim ctl As Control
Open App.Path & "\tempdata.txt" For Input As #1
Do Until EOF(1)
Line Input #1, strLine
If Not Trim(strLine) = "" Then
pos = InStr(1, strLine, " ")
For Each ctl In Me.Controls
If ctl.Name = Mid(strLine, 5, pos - 1 - 4) Then
If Left(strLine, 3) = "lbl" Then
ctl.Caption = Mid(strLine, pos + 1)
ElseIf Left(strLine, 3) = "txt" Then
ctl.Text = Mid(strLine, pos + 1)
End If
End If
Next ctl
End If
Loop
Close #1
End Sub