View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Philip Philip is offline
external usenet poster
 
Posts: 156
Default Simple Calculation

Try
CODE
Private Function IzracunDDV() As Boolean

If VBA.CInt(TextSkupajDDV.Value) _
+ VBA.CInt(TextBrezDDV.Value) = VBA.CInt(TextSkupajZDDV.Value) Then
IzracunDDV = True
Exit Function
End If

Application.ScreenUpdating = True
IzracunDDV = False
End Function
<<<< END CODE

to check that 3 numbers are the same you need to force them to be numbers.

The default property of a textbox is the Text property, so in fact, if you
don't get the Value property explicitly, then the test you are performing is
like this:

text1 + text2 = "12"

is "12" = "3"

answer, FALSE

But if you take the textbox value property (which is still a string BTW)
then cast it to an integer using CINT then you get this test:

1 +3 = 3

One more thing, you are returning "IzracunDDV = False" if the condition is
found to be true - is that correct?

HTH

Philip
"Lucifix" wrote:


But what is different then this:

Private Function IzracunDDV() As Boolean

If TextSkupajDDV + TextBrezDDV = TextSkupajZDDV Then
IzracunDDV = False
Exit Function
End If

Application.ScreenUpdating = True
IzracunDDV = True
End Function

Lets say that I would like to insert in fields:
TextSkupajDDV - 2
TextBrezDDV - 1
TextSkupajZDDV - 3

This function will say that this is not correct, which isn't true.
2 + 1 = 3

What would be right function then?

Thank you for helping me.
Lucifix


--
Lucifix
------------------------------------------------------------------------
Lucifix's Profile: http://www.excelforum.com/member.php...o&userid=29179
View this thread: http://www.excelforum.com/showthread...hreadid=495452