Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Q: A first chance exception error. Please review my code (me = newb)
i've just started with vb.net, and when i run this little thingy i created i get the following error:
[italic]"A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll"[/italic]
The program works fine though.
I've read a bunch of articles about this error, and it turns out it's not that uncommon ([link=http://blogs.msdn.com/davidklinems/archive/2005/07/12/438061.aspx]link[/link]
), but I'd really like to know what's causing it and if I can prevent it.
Here's my code
[code]Public Class Form1
Private gobank As Bankrekening
Public Sub New()
' This call is required by the Windows Form Designer.
' Add any initialization after the InitializeComponent() call.
Private Sub Initialize()
gobank = New Bankrekening()
TextBox1.Text = CInt(0)
Label3.Text = CInt(0)
Label4.Visible = False
Label7.Visible = False
Label8.Visible = False
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rekeningsaldo As Integer
rekeningsaldo = TextBox1.Text
If RadioButton1.Checked = True Then
Label6.Text = "(+) Je hebt zonet " & CStr(rekeningsaldo) & "