Function Warning - Null Reference
- From: "Terry" <news-grps@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 12 Jan 2007 21:49:28 -0000
I am getting the following warning for the below function. I understand what
it means but how do I handle a null reference? Then how do I pass the
resulting value?
Regards
Warning 1 Function 'Dec2hms' doesn't return a value on all code paths. A
null reference exception could occur at run time when the result is used.
G:\Project Development\Visual Studio
2005\Projects\Ascension\Ascension\SwephConversions.vb 64 3 Ascension
' Convert decimal hours to hours/minutes/seconds
Public Function Dec2hms(ByVal x As Decimal) As String
Dim hh As Int32, mm As Int32, ss As Decimal, remainder As Decimal
'Dim x a decimal, hh as integer
hh = CType(x, Integer)
remainder = (x - hh)
mm = CType((remainder * 60), Integer)
remainder = ((remainder * 60) - mm)
ss = Int(remainder * 60)
remainder = ((remainder * 60) - ss)
If remainder >= 0.5 Then
ss = ss + 1
Else
ss = ss
End If
hms = hh & "h " & mm & "m " & ss & "s"
End Function
.
- Follow-Ups:
- Re: Function Warning - Null Reference
- From: Terry
- Re: Function Warning - Null Reference
- From: Tom Shelton
- Re: Function Warning - Null Reference
- From: Stephany Young
- Re: Function Warning - Null Reference
- Prev by Date: Creating objects dynamically in a loop
- Next by Date: Re: Startup object
- Previous by thread: Creating objects dynamically in a loop
- Next by thread: Re: Function Warning - Null Reference
- Index(es):
Relevant Pages
|
Loading