VB shut down queery

Permabanned
Joined
28 Oct 2006
Posts
6,552
Location
Bournemouth
I'm making a super simple program with this outline

You stick it in the startup folder, you boot up

Window pops up, asks you to enter anything you want reminding about when you log off (i.e. memory stick, pick up news paper etc)

Then being vb it obviously remebers this.

However i need to trigger a msgbox when the end command is issued. Sort of like when you have a word document open and you click shutdown it will pop up asking if you want to save discard or cancel.

I'm just using

If (Label1.Text = "") Then End Else Me.Hide() ---- (where label1 is the place you type your reminder)

to put the program in dormant mode.

However i don't know where to insert this code:

If (Label1.Text = "") Then End Else MsgBox(Label1.Text, MsgBoxStyle.Exclamation, "REMEMBER")

Any help much appreciated.
 
In VB.NET something like this? You won't need the second if statement...

Code:
Private Sub Form1_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
        MsgBox(Label1.Text)
    End Sub
 
Nope codes not working. The new vb's just don't seem to work as well as the old vb6.

If (Label1.Text = "") Then End Else Me.Hide()

that bit of code seems non effective. If you don't type anything the program doesn't end and when i run the kill the process nothing happens.
 
Just needs a form with 1 button and 1 textbox on it.
Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If String.IsNullOrEmpty(TextBox1.Text) Then
            End
        Else
            Me.Hide()
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Not String.IsNullOrEmpty(TextBox1.Text) Then
            MsgBox(TextBox1.Text)
            TextBox1.Text = String.Empty
            End
        End If
    End Sub
End Class
 
Sadly you can't!
Killing the process or stopping VS terminates without running the code.
As the only form is hidden you can't use that to fire the event.

Build the EXE, close VS, run the exe, stick in your text, click the button and shut down/restart your PC.
Log on/off might also work.

You could try moving the final code to other form events to see if any fire when you close the project.
 
Last edited:
cool it works. See i toyed with all the preset form functions in the drop down list and i saw deactivate form closing etc etc but due to me not publishing the exe first i didn't know that vb terminated rather than closed it normally. Thanks it is fully working now :)
 
Back
Top Bottom