Solved

vb6 code conversion to vb 2008

Posted on 2008-10-22
3
424 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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…

823 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