Inner Exception Unhandled in VB Express project...
Greeting everyone! Thank you in advance for your help. Here is my problem. I am trying to code a simple weather tracker program in VB Express. I have it built, but it always throws an exception in my 'ExtractTemperature' Function. Let me post that function:
[align=center]Private Function ExtractTemperature() As Double
If (lblTemperatureCurrent.Text.Length = 0) Then
' Returning only the number portion ignoring the
' degree F
Return CDbl(lblTemperatureCurrent.Text.Substring(0, _
The 'lblTemperatureCurrent.Text is supposed to be in the form of an integer followed by the degree symbol followed by F. The function should strip the degree symbol and F off the integer, returning just the integer value. I am under the impression that the lblTemperatureCurrent.Text.IndexOf function is returning a -1 which is throwing the exception. How can I get the value of lblTemperatureCurrent.Text at that point so I can tell if it is a problem with the value of the variable or the fault of the function itself? Again, thank you for your help.
Re: Inner Exception Unhandled in VB Express project...
hi, i'm rubbish at coding, but if the error is where you think it is then i'd imagine the problem is the search for index of [degree symbol] could be something to do with keyboard character codes or something.
you should be able to convert the symbol or lookup the ascii code for it and search for that. i'm not sure how the symbol ends up in the variable anyway.
to debug, at the point where the function is called just do a messagebox that outputs the variable:
that might shed more light on it.
alternatively, you can do a count from the end of the variable, i.e. show text from 0 to variable.text.length - 2 or something like that.
the bit i'm not sure about is if you declare the function as double in the first part of the if statement, can you return integer.minvalue? is that allowed?
hope it helps