Results 1 to 5 of 5

Thread: Event and Exception Changes for Visual Basic 6?

  1. #1
    Join Date
    Apr 2009
    Posts
    515

    Event and Exception Changes for Visual Basic 6?

    Hi friends,
    I have recently started with the Visual Basic and so I am not having much idea about it. I want to know about the Event and Exception Changes that occurs in VB. So please explain me about an Event and Exception Changes for Visual Basic 6? Help me as soon as possible.!!

  2. #2
    Join Date
    Mar 2008
    Posts
    349

    Re: Event and Exception Changes for Visual Basic 6?

    Events and exceptions are class members that are used to signal changes in the class to the client code. Typically, an event signals an expected change, and the client code can choose to respond or not. Exceptions signal an error state, and the client code ignores this at its own risk. The syntax for declaring an event has not changed from Visual Basic 6.0 :
    Code:
    Public Event StateChanged()

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Event and Exception Changes for Visual Basic 6?

    Exceptions are not supported in Visual Basic 6.0, but raising an error is. Errors are caught using On Error GoTo statements in conjunction with labeled statements. Try...Catch...Finally Statement (Visual Basic) block structure is used to respond to exceptions. An example is shown below :
    Code:
    Dim big As Integer = Integer.MaxValue
    Dim bigger As Integer = Integer.MaxValue
    Try
        Dim biggest As Integer = big + bigger
    Catch ex As Exception
        MsgBox("Addition did not succeed.")
    End Try

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Event and Exception Changes for Visual Basic 6?

    Code that raises errors in Visual Basic 6.0 is converted to code that raises errors in Visual Basic 2005. Here is an example of converted code that raises an error :
    Code:
    Private mvarAge As Short
    Public Property Age() As Short
        Get
            Age = mvarAge
        End Get
        Set(ByVal Value As Short)
            If Value >= 0 Then
                mvarAge = Value
            Else
                Err.Raise(vbObjectError + 2, Me, _
                    "Age must be greater than or equal to zero.")
            End If
        End Set
    End Property

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: Event and Exception Changes for Visual Basic 6?

    Using an exception instead requires only replacing the Err.Raise call with a Throw Statement (Visual Basic). Another benefit is that the error number can be eliminated. When upgrading events and exceptions to Visual Basic, consider the following :
    • Replacing On Error GoTo statements with Try statements.
    • Replacing Err.Raise with Throw
    • Using the parameter conventions for events (Public Event StateChanged(ByVal sender As Object, ByVal e As EventArgs)).
    • Creating custom exceptions and EventArgs classes through inheritance.

Similar Threads

  1. what are Visual Basic IDE?
    By Naresh Modi in forum Software Development
    Replies: 2
    Last Post: 06-03-2009, 09:49 AM
  2. Is GUI same like Visual Basic ?
    By Caesar in forum Software Development
    Replies: 2
    Last Post: 02-03-2009, 01:32 PM
  3. How can i use the mouse OFF event in visual basic?
    By Pooja in forum Software Development
    Replies: 2
    Last Post: 26-02-2009, 08:52 PM
  4. Visual Basic 2005 or Visual Basic 6
    By Aasha in forum Software Development
    Replies: 5
    Last Post: 15-01-2009, 06:56 PM
  5. Visual Basic on LAN
    By djbbenn in forum Software Development
    Replies: 2
    Last Post: 05-08-2008, 02:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,999,339.83749 seconds with 17 queries