![]() | Register | FAQ | Members | Social Groups | User Map | Calendar | Search | Today's Posts | Mark Forums Read |
| | | LinkBack | Thread Tools | Search Thread | Language |
| Sponsored Links |
| | #1 |
![]() Join Date: Jul 2007 Location: Michigan
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 | 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 Return Integer.MinValue Else ' Returning only the number portion ignoring the ' degree F Return CDbl(lblTemperatureCurrent.Text.Substring(0, _ lblTemperatureCurrent.Text.IndexOf("ยบ"))) End If End Function[/align] 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. |
| |
| | #2 |
![]() | 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: msgbox(lblTemperatureCurrent.text) 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 |
| |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SIMS SQL upgrade. To Express or not to Express? | woody | MIS Systems | 5 | 16-10-2007 04:34 PM |
| ICT Project Manager | SpecialAgent | Educational IT Jobs | 0 | 28-02-2007 07:03 PM |
| Gizmo Project | CyberNerd | Educational Software | 0 | 02-10-2006 09:47 PM |
| new toys - Project MIX I/O | plexer | Hardware | 0 | 15-08-2006 01:10 PM |
| An interesting CDT project maybe? | Ric_ | Jokes/Interweb Things | 1 | 12-04-2006 08:34 PM |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search Thread |
|
|





