June 12th, 2013, 01:22 AM
Handled Runtime Exception not sure how to fix it.
I think I've narrowed down where the exception is actually coming from:
Private Sub cmbDBType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbDBType.SelectedIndexChanged
Dim DBType As String
DBType = cmbDBType.SelectedItem.ToString
Select Case DBType
txtDBPort.Text = "1443"
txtDBPort.Text = "3306"
txtDBPort.Text = "5432"
If cmbDBType.SelectedItem Is "MSSQL" Or cmbDBType.SelectedItem Is "PostgreSQL" Then
MessageBox.Show("Feature not yet implemented", "Option Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
When I run the program, it throws this exception:
I've looked through other forums and I turned on Option Strict and had to make some changes, namely the Is statements. Others in those other forums say to tell the compiler not to show those warnings. I'm using Visual Studio 2012 and .NET 4. Is my code good and VB is being picky, or can I improve this code so it doesn't throw the error? If so, how? I haven't messed with VB in quite some time so I'm a bit rusty with it.
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
I fiddled around with it for a while and then got frustrated and saved and closed VS2012. When I opened it back up I didn't get the error anymore. Must've not cleared it when it was fixed.
Last edited by winblowzxp; June 12th, 2013 at 01:15 PM.
Reason: Solution found