Error: Conversion from string “0” to type ‘Integer’ is not valid
During a recent rollout at my company we would encounter the error message above on some PCs. The PCs were running either Windows 2000 or Windows XP with the latest service packs installed. I believed the error was coming from the Microsoft.VisualBasic.dll.
I found a workaround online which is included here:
Modify the registry key
so that its value is nothing.
If it appears as though the value is already empty (as it did in my case), edit the data string to some arbitrary viewable character, save it, open it up again and remove the value.
Changing this setting is per user, so you may have to apply this change for every user of the PC.
The code were the error occurs was reading a value from a database and casting it to an integer. Here is the VB code:
Dim drcInfo As DataRowCollection
Dim intFieldValue As Integer = 0
‘…drcInfo filled with data (missing)…
For Each drDataRow As DataRow In drcInfo
intFieldValue = CInt(drDataRow.Item(0).ToString)
This is a known bug and there is a Microsoft knowledge base article here: