Results 1 to 11 of 11

Thread: Why my Application is closing?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2012
    Posts
    119

    Why my Application is closing?

    When I click on a button or LinkLabel my application closes automatically.
    Why is this happening?

  2. #2

    Re: Why my Application is closing?

    Well I don't know. Some code behind or perhaps a screenshot or something would be great! Does it exception? Do you have the debugger attached? Is it cooking you bacon in the kitchen when it should be dicing tomatoes?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2012
    Posts
    119

    Re: Why my Application is closing?

    When I click on LinkLabel here is the code behind it
    Code:
     Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
            
            Freshuser.Show()
            Me.Hide()
        End Sub
    And here is the code behind the form_load code
    Code:
    Private Sub Freshuser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'add items to combo
            Me.ComboBox1.Items.Add("What is my pet's name?")
            Me.ComboBox1.Items.Add("What is my fav colour?")
            Me.ComboBox1.Items.Add("Who is my fav film personality?")
            Me.ComboBox1.Items.Add("what is my fav food?")
            Me.ComboBox1.Items.Add("what is my fav song?")
            
           
            'select index
            Me.ComboBox1.SelectedIndex = 0
            'select last item
            Me.ComboBox1.SelectedIndex = Me.ComboBox1.Items.Count + 1
            Me.BackColor = Color.Beige
            Button1.Enabled = False
        End Sub
    But it does not show up It just make the application close.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Why my Application is closing?

    Does an error message appear, if so what does it say?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: Why my Application is closing?

    Hi,

    Add a Try/Catch block around that code in the Freshuser Form's Load event and you will see what is wrong. Don't forget that all collections in .NET are indexed from Zero.

    Hope that helps.

    Cheers,

    Ian

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2012
    Posts
    119

    Re: Why my Application is closing?

    Code:
    Me.ComboBox1.SelectedIndex = Me.ComboBox1.Items.Count + 1
    I have changed +1 to -1 ,so now it worked.

  7. #7
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Why my Application is closing?

    Changing the label sub in post #3 to

    vb.net Code:
    1. Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click
    2.         Freshuser.Show()
    3.         Me.Hide()
    4.     End Sub

    seemed to work! Although, I have not seen the "_LinkClicked" method before.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: Why my Application is closing?

    @Nightwalker83,

    seemed to work! Although, I have not seen the "_LinkClicked" method before.
    Just for info, the control type being used was a LinkLabel and not a Label which exposes additional properties and events such as LinkClicked.

    Cheers,

    Ian

  9. #9
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Why my Application is closing?

    Ah ok, forget what I said in post #3.
    Last edited by Nightwalker83; Jul 6th, 2013 at 11:03 PM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  10. #10
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Why my Application is closing?

    @chdboy

    Are you running on a Win7 x64 or any other 64 bit Windows by any chance ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  11. #11

    Re: Why my Application is closing?

    Based on what I've seen, it appears that he was (most likely) getting an IndexOutOfRange Exception in the Form load which, as Niya was going to go to, on 64 Bit windows, exceptions in the form load event are swallowed and ignored.

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