Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
EXCEL NEWS,
First, how is this not working? It works for me.......although I don't know what the expected results should be. Are there errors? Are the results wrong? Please provide values, expected results, and the incorrect results you are recieving. Second, this code consolidates things a little (notice I commented out your code and replaced it with less code that will accomplish the same thing): Function Length024Round(l As Double) As Double Dim seisuu As Double Dim hasu As Double Dim hasu1 As Double seisuu = Fix(l) MsgBox seisuu hasu = l - seisuu MsgBox hasu 'If hasu < 0.24 Or hasu = 0.24 Then If hasu <= 0.24 Then hasu1 = 0 'ElseIf hasu 0.24 And hasu < 0.74 Then ElseIf hasu 0.24 And hasu <= 0.74 Then hasu1 = 0.5 'ElseIf hasu = 0.74 Then 'hasu1 = 0.5 ElseIf hasu 0.74 Then MsgBox "hasu" & hasu hasu1 = 1 End If MsgBox hasu1 Length024Round = seisuu + hasu1 End Function HTH, Conan "EXCEL$B!!(BNEWS" wrote in message ... hi,help me please, what is wrong with my fun ,thanks -------------------------------------------------------- Function Length024Round(l As Double) As Double Dim seisuu As Double Dim hasu As Double Dim hasu1 As Double seisuu = Fix(l) MsgBox seisuu hasu = l - seisuu MsgBox hasu If hasu < 0.24 Or hasu = 0.24 Then hasu1 = 0 ElseIf hasu 0.24 And hasu < 0.74 Then hasu1 = 0.5 ElseIf hasu = 0.74 Then hasu1 = 0.5 ElseIf hasu 0.74 Then MsgBox "hasu" & hasu hasu1 = 1 End If MsgBox hasu1 Length024Round = seisuu + hasu1 End Function ' Sub Length024RoundTest() Debug.Print Length024Round(0.74)----0.5--ok Debug.Print Length024Round(2.74))----3.0--why$B!!(Bnot$B!!(B2.5,why 0.740.74 End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Insert Calculated Field (wrong Qty*Price = wrong Amount) | Excel Discussion (Misc queries) | |||
What could be wrong? | Excel Programming | |||
What am I doing wrong, here? | Excel Programming | |||
What am I doing wrong? | Excel Programming | |||
What am I doing wrong? | Excel Programming |