[RESOLVED] [VB/03] Unhandled exception error when running program
Hi,
I am getting an unhandled exception error when I run my program:
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
Additional information: Cast from string "9245-8601-6933-291" to type 'Double' is not valid.
It doesn’t write the value to registry string as it is supposed to, and breaks on
If txtLicense.Text = LicNum Then
From the code block:
'Change License Number String Value for QuickBooks Premier 2006
If ckBoxLic.Checked = True Then
If ckBox2006.Checked = True Then
If ckBoxPrem.Checked = True Then
If txtLicense.Text = LicNum Then
Dim regKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\Intuit\QuickBooksRegistration\16.0\superp ro", True)
If Not regKey Is Nothing Then
regKey.SetValue("LicNum", "LicenceNumber")
End If
End If
End If
End If
Else
Exit Sub
End If
I have imported “System” and “Microsoft.32”; I also used the statement “Strict Options Off to try and fix this by converting the data type implicitly. I am very new to VB.Net so any advice on what I am doing wrong is greatly appreciated.
Re: [VB/03] Unhandled exception error when running program
TextLicense.Text is a string, and I am guessing LicNum is declared as a Double. You cannot compare a string to a double, they are different types. You would have to either change the LicNum variable to a string or convert the TextLicense.Text string to a Double so they will be the same type. Then you can see if the two are equal or not.
Re: [VB/03] Unhandled exception error when running program
yep that was it, thanks
now I just have to figure out why it is not writing the value to the registry key. woo hoo almost there!