"Type Mismatch" bug and line numbers in the Auto FE Updater
I've been getting intermittent email reports of a "Type Mismatch" error message in the Auto FE Updater. However the problem just wasn't making any sense. Thankfully the most recent person who emailed me was quite persistent and so the problem is solved pending the last version he is going to be testing very shortly.
The lengthy amount of delay in figuring out the problem was exacerbated by my own stupidity. I use a lot of API and other code especially from Randy Birch's VBnet Visual Basic Developers Resource Centre. I didn't bother adding my standard error handling routine in much of the code for whatever foolish rationale I can't quite figure out now. In hindsight of course. So the error message was passed back to upper level procedures where there was no numeric handling so I was greatly puzzled as to how some string manipulation was causing "Type Mismatch" messages.
Turns out the problem was due to converting the OS version number "5.1" string (meaning Windows XP) in systems where the decimal symbol is , (comma).
In that code look for the line
Text1(1).Text = win.VersionNum
In that example the code is being converted to a string so no problem. However my code converted it to a Single variable.
Now when I set the decimal symbol to comma on my own system the number gets converted to 51. And not 5.1. I'm not quite sure why Norwegians and others are getting type mismatch. But I'm not going to worry about that for now.
Thanks also to MZTools for having buttons to add and remove line numbers from subroutine and function calls. This allowed me to ship new versions of the Auto FE Updater to the tester and narrow down the line in the routines causing the problem. You can use the variable Erl to display the line number of the line of code causing the problem.
MsgBox "The following error occurred in procedure GetWinVerAll of Module APICalls" & vbCrLf & vbCrLf & _
Err.Description & vbCrLf & "Line Nbr: " & Erl & vbCrLf & vbCrLf & Command() & _
gblstrSupportMsg & gblstrCopyrightNotice
There are a variety of methods to determine the decimal symbol including API calls such as GetLocaleInfo: Regional Locale Numeric Settings. However Rick Rothstein, fellow MVP had the following elegant solutions.
DecimalPoint = Format$(0, ".")
DateSeparator = Format$(0, "/")
ThousandsSeparator = Mid$(Format$(1000, "#,###"), 2, 1)
P.S. In another day or two I'll have a release of the Auto FE Updater which solves this problem.