On Exit?

Stix19

Newcomer
Joined
Feb 15, 2003
Messages
4
I basically want VB to write a variable to a text file when the person clicks the X, since there will be no exit button.

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Dim objstreamwriter As System.IO.StreamWriter
objstreamwriter = System.IO.File.AppendText ("numbers1.txt")
objstreamwriter.WriteLine(intfinal)
End Sub

That's what I have right now, intfinal is a variable that is constantly updated in the program in another sub procedure. I tried using objstreamwriter.writeline(val(me.label.text)) but that didn't work either.

What exactely is the Base Class Event for exit? And what code should I use?

Thanks guys.
 
Ok, I figured that one out by myself. I accidentally used closed instead of closing.

My next question, the program I'm running is counting key presses. I want to have the program count all key presses done in windows, not just when the form window is up and running in the front. For that, I need an option to make the window always on top, and I need it to count even when its not. Any ideas on how to do that? The program is already coded and works fine, it just won't stay on top.

I found vb6 code but that obviously doesnt work.
 
Back
Top