Index was out of range. Must be non-negative and less than the size of the collection

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Apr 2007
Posts: 1
Reputation: Ashok2007 is an unknown quantity at this point 
Solved Threads: 0
Ashok2007 Ashok2007 is offline Offline
Newbie Poster

Index was out of range. Must be non-negative and less than the size of the collection

 
0
  #1
Apr 12th, 2007
Index was out of range. Must be non-negative and less than the size of the collection Hi,

I've a form and the form is working fine also. But my problem is
Whenever I closed the form. I'm getting two errors.

1.Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

2.Arithmetic overflow error converting varchar to data type numeric.
The statement has been terminated.


Events are :
Private Sub btnFilClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFilClose.Click, btnBrowClose.Click

'This event is used to close the form

Try
Me.Cursor = Cursors.WaitCursor
Me.Close() ' I'm getting the error on this line
Me.Cursor = Cursors.Default
Catch ex As Exception
Me.Cursor = Cursors.Default
MessageBox.Show(ex.Message)
Finally
Me.Cursor = Cursors.Default
Me.Close()
End Try
End Sub

Private Sub forms_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'This event will be fired automatically whenever form will be closing

Try
Me.Cursor = Cursors.WaitCursor
If MessageBox.Show("Do you want to close this form", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then

'If user press Yes then Form will be closed
Me.Cursor = Cursors.Default
e.Cancel = False
Else

'If User press No the Form will be not closed
e.Cancel = True
End If
Me.Cursor = Cursors.Default
Catch ex As Exception
Me.Cursor = Cursors.Default
MessageBox.Show(ex.Message)
End Try
End Sub

Please help me

Thanx in advance
Ashok
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: Index was out of range. Must be non-negative and less than the size of the collection

 
0
  #2
Apr 12th, 2007
What is index? Where are you using it? Where are you using varchar to data type numeric? There is something wrong here not in your closing, it looks fine to me.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC