-
Jul 6th, 2013, 02:57 AM
#1
Thread Starter
Lively Member
Why my Application is closing?
When I click on a button or LinkLabel my application closes automatically.
Why is this happening?
-
Jul 6th, 2013, 03:13 AM
#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?
-
Jul 6th, 2013, 03:54 AM
#3
Thread Starter
Lively Member
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.
-
Jul 6th, 2013, 03:58 AM
#4
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
-
Jul 6th, 2013, 04:04 AM
#5
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
-
Jul 6th, 2013, 04:07 AM
#6
Thread Starter
Lively Member
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.
-
Jul 6th, 2013, 04:11 AM
#7
Re: Why my Application is closing?
Changing the label sub in post #3 to
vb.net Code:
Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click Freshuser.Show() Me.Hide() 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
-
Jul 6th, 2013, 04:20 AM
#8
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
-
Jul 6th, 2013, 04:43 AM
#9
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
-
Jul 6th, 2013, 05:32 AM
#10
Re: Why my Application is closing?
@chdboy
Are you running on a Win7 x64 or any other 64 bit Windows by any chance ?
-
Jul 6th, 2013, 11:27 AM
#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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|