Solved

vb6 code conversion to vb 2008

Posted on 2008-10-22
3
434 Views
Last Modified: 2010-04-21
I am new to visual basic and I was assigned the task of converting some old VB6 code to VB2008.
I have almost everything in the application converted exept this one close routine that closes the applicataion.

What i am going to attach is what the vb6 code was. I ran the conversion tool and it is giving me this error that you see in the code snippet. I need to know what to put in the place of the "cancel" or if that is not the fix I need to know what is. The "Cancel" statement is what it is barking about..
Private Sub frmSpecialMailout_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		If Me.cmdStart.Enabled = False Then
       MsgBox("App is currently running.  Please wait for App to stop.")
'UPGRADE_ISSUE: Event parameter Cancel was not upgraded. 
                      Cancel = 1
		Else
		   Me.Close()
		End If
		
		
	End Sub

Open in new window

0
Comment
Question by:lvandevender2008
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 22777323
Hi lvandevender2008,

You need to use the FormClosing event, because by the time it gets to the FormClosed event it's too late to cancel.

Regards,

Wayne
    Private Sub frmSpecialMailout_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Me.cmdStart.Enabled = False Then
            MsgBox("App is currently running.  Please wait for App to stop.")
            e.Cancel = True
        Else
            Me.Close()
        End If
    End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22777397
First thing is that you should not be doing this validation in form_closed event. You should be doing in Form_Closing event

Private Sub frmSpecialMailout_FormClosing(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosing
                If Me.cmdStart.Enabled = False Then
       MsgBox("App is currently running.  Please wait for App to stop.")
'UPGRADE_ISSUE: Event parameter Cancel was not upgraded.
                      eventArgs.Cancel = true
                Else
                   Me.Close()
                End If
               
               
        End Sub


0
 

Author Closing Comment

by:lvandevender2008
ID: 31508775
Best answer of the two. I tried both sets of code and this one was the only one that compilied correctly and worked. Good job man!!!!
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question