How to save the tentative result and get the string recovered?

C

cyberdude

Hi,

I put a userform in my VBA code. Textbox1 contains a string which is
the most important result of the userform. Its length increases as
the programme runs. The string can be very long.

Due to some unknown reasons or bugs, the programme halts occasionally
and it prompts me to either detect the error or end the programme. As
a result, the string in textbox1 is lost.

I want to do some rescue action when the programme halts. Therefore,
I figure out the following way to do it: I want to save the string in
textbox1 whenever its length changes. Hence, I need to open a file,
save the string in textbox1 in that file and close it. So, I hope
that someone can tell me how to do these steps.

In addition, I would like to know if there is another better or easier
way to get the string recovered if the programme halts. Thanks.

Mike
 
D

Doug Robbins - Word MVP

Probably best if you give us some idea a what the "programme" is doing.
Copying and pasting the code into a message that you post back here would
help.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
H

Helmut Weber

Hi Mike,

perhaps like that:

Option Explicit
Dim l As Long
' ------------------------------------------
Private Sub TextBox1_Change()
If l <> Len(TextBox1.Text) Then
Open "c:\test\test.txt" For Output As #1
Print #1, TextBox1.Text
Close #1
End If
l = Len(TextBox1.Text)
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top