Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function returning 0

Status
Not open for further replies.

Leslie67

Programmer
Jul 23, 2002
42
US
I have a function call to convert feet to meters in my main form that looks like this:

txtTotalDepth.Value = Convert(txtTotalDepth.Value)

This calls the Conversion function which looks like this:

Function Convert(dblValue As Double) As Double
'Converts the measurement to metres
Dim dblresult As Double

dblresult = (dblValue * 0.3048) 'convert from feet to metres
dblresult = RoundAL(dblresult, 2) 'round off to two places

End Function

The Convert function calls a rounding function which works just fine...

I've stepped through the whole procedure watching the values to make sure they're correct.

The problem comes in passing the value *back* to the initial function... even when the final result of dblresult is, for example 213.36, the txtTotalDepth.Value ends up as 0.

Can somebody PLEASE tell me what I've done wrong? It's driving me nuts!

Thanks...
 
Pass the results back through the Function Name.

Function Convert(dblValue As Double) As Double
'Converts the measurement to metres
Dim dblresult As Double

dblresult = (dblValue * 0.3048) 'convert from feet to metres
Convert = RoundAL(dblresult, 2) 'round off to two places

End Function
 
Thank you so much...

That was it exactly...

I knew it was something stupid <g>

You have saved me untold hours of aggravation and I really, really appreciate it...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top