Solved

vb6 code conversion to vb 2008

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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