Results 1 to 11 of 11

Thread: The application crashes when a form appears

  1. #1

    Thread Starter
    Addicted Member JackIlPazzo's Avatar
    Join Date
    Oct 2014
    Posts
    183

    The application crashes when a form appears

    I made a code which is able to save in two lists results in real time from a web page, so far everything has worked very well, then I decided to add an additional feature and that is to show the results that have changed (ie when a team scored a goal), in a form of notifications.
    I then made an additional form called "notifiche" and I implemented the procedure as follows:

    Code:
    Dim keepLogging As Boolean = True
    
                    If popup = True Then 'this variable is valorized when the form's minimized
    
                        For Each abc As Country_Data In lista
                            For Each xyz As Country_Data In vecchia_lista
                                If abc.casa = xyz.casa And abc.ospite = xyz.ospite Then
                                    If abc.result <> xyz.result Then
                                        show_popup(abc.casa, abc.ospite, abc.minuto, abc.result)'function that show the notification
                                        keepLogging = False
                                        Exit For
                                    End If
                                End If
                            Next
                            If (Not keepLogging) Then Exit For
                        Next
                    End If
    all the code works very well, the results that have changed are shown, the problem lies in the form of notification. In particular when the notification should appear the application crashes. I can't explain why because if I open the form "notifiche" for example by pressing a button with "notifiche.show()", this shows no problem opening.

    Code:
    Function show_popup(casa, ospite, risultato, minuto)
                notifiche.Show()
                notifiche.MetroLabel1.Text = casa
                notifiche.MetroLabel2.Text = risultato
                notifiche.MetroLabel3.Text = ospite
                notifiche.MetroLabel4.Text = minuto
    End Function
    This is the class of notifiche form:

    Code:
    Public Class notifiche
        Dim i As Integer = 0
        Private Sub notifiche_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.Location = New Point( _
                Screen.PrimaryScreen.Bounds.Width - 400, _
                Screen.PrimaryScreen.Bounds.Height)
        End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            If Me.Opacity = 0 Then Me.Close()
    
            If i = 500 Then
                Me.Opacity -= 0.02
            End If
    
            If Not Me.Location.Y = Screen.PrimaryScreen.WorkingArea.Height - 200 Then
                Me.Location = New Point(Me.Location.X, Me.Location.Y - 2)
            End If
    
            If Not i = 500 Then i += 1
        End Sub
    End Class
    I can provide more details, but please help me to solve this problem because I can't understand the cause.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,439

    Re: The application crashes when a form appears

    A crash is an unhandled exception. If there's an exception then there's an error message, provided specifically for diagnostic purposes.

  3. #3

    Thread Starter
    Addicted Member JackIlPazzo's Avatar
    Join Date
    Oct 2014
    Posts
    183

    Re: The application crashes when a form appears

    It's not really a crash ... the application is still running, only that it is locked. May depend animazinoi I inserted in form notifications?

  4. #4
    Frenzied Member Bulldog's Avatar
    Join Date
    Jun 2005
    Location
    South UK
    Posts
    1,950

    Re: The application crashes when a form appears

    Run it in debug mode, stepping through the code until something goes wrong.

    If it's a "crash", you could also put show_popup() in a try/catch to show any exceptions.

    VB Code:
    1. Try
    2.     DoSomething()
    3. Catch ex As Exception
    4.     MessageBox.Show(ex.Message)
    5. End Try


    • If my post helped you, please Rate it
    • If your problem is solved please also mark the thread resolved

    I use VS2015 (unless otherwise stated).
    _________________________________________________________________________________
    B.Sc(Hons), AUS.P, C.Eng, MIET, MIEEE, MBCS / MCSE+Sec, MCSA+Sec, MCP, A+, Net+, Sec+, MCIWD, CIWP, CIWA
    I wrote my very first program in 1979, using machine code on a mechanical Olivetti teletype connected to an 8-bit, 78 instruction, 1MHz, Motorola 6800 multi-user system with 2k of memory. Using Windows, I dont think my situation has improved.

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,112

    Re: The application crashes when a form appears

    If Not Me.Location.Y = Screen.PrimaryScreen.WorkingArea.Height - 200 Then
    Are you sure when you change the location of the form that it will hit that row of pixels exactly.
    I would never assume that, and if not, then your form will be changing position continually, until it probably eventually will crash.

    I would use <= so I stop near 200. Since you're moving by 2 pixels at a time, if it doesn't stop at 200, it should stop at 199.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,953

    Re: The application crashes when a form appears

    Are you trying to implement a toast notification? Look in the Codebank for .NET... I know someone at one point posted a method for displaying toast notifications.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,439

    Re: The application crashes when a form appears

    Quote Originally Posted by techgnome View Post
    Are you trying to implement a toast notification? Look in the Codebank for .NET... I know someone at one point posted a method for displaying toast notifications.

    -tg
    There may be others, but here's mine:

    http://www.vbforums.com/showthread.p...emo&highlight=

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,953

    Re: The application crashes when a form appears

    That was the one I was thinking of...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Addicted Member JackIlPazzo's Avatar
    Join Date
    Oct 2014
    Posts
    183

    Re: The application crashes when a form appears

    @BullDog

    Isn't generated any exceptions.

    @passel

    I'm trying your solution, as soon as I have time I will let you know

    @techgnome

    if the solution of @passel don't work, I'll be happy to take a look at the code of @jmcilhinney

    UPDATE: I could see that this happens with every form I try to open the loop to display the notification
    Last edited by JackIlPazzo; Feb 9th, 2015 at 04:30 AM.

  10. #10

    Thread Starter
    Addicted Member JackIlPazzo's Avatar
    Join Date
    Oct 2014
    Posts
    183

    Re: The application crashes when a form appears

    No more hint?

  11. #11
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,112

    Re: The application crashes when a form appears

    It sounds like you might be stuck in a loop.

    Run the program in the IDE.
    When it hangs, press the Break button in the IDE (looks like the pause on a media player).
    Then take a step in the debugger (usually you can press F11).
    Note what line you're on and what you're doing.
    Continue stepping to see why you're hung up.

    If your initial step doesn't stop at a line of your code, then it would appear that some object method you called may be hung waiting for something. Hard to tell from here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width