Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Search Today's Posts Mark Forums Read

Go Back   EduGeek.net Forums > Coding and Web Development > Coding
Reply
 
LinkBack Thread Tools Search Thread Language
Sponsored Links
Old 05-07-2007, 03:57 AM   #1
 
rmetz527's Avatar
 
Join Date: Jul 2007
Location: Michigan
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 rmetz527 is an unknown quantity at this point
Default 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

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.
  Reply With Quote
Old 08-11-2007, 01:44 PM   #2
 
vikpaw's Avatar
 
Join Date: Sep 2006
Location: wellingborough, northants
Posts: 137
uk uk england
Thanks: 5
Thanked 9 Times in 4 Posts
Rep Power: 7 vikpaw will become famous soon enough
Send a message via MSN to vikpaw
Default 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:

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
  Reply With Quote
Reply

Register now for FREE and post messages!


Username: Password: Confirm Password: E-Mail: Confirm E-Mail:
Birthday:      
Image Verification
  I agree to forum rules 

Similar Threads
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
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +1. The time now is 07:45 PM.
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright EduGeek.net