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

Hi,

That's because TextSkupajDDV + TextBrezDDV = string AND string, not number
plus number.

By default, VBA concatenates strings, and the default property of a textbox
is the text property, which is a string data type.

so, if you enter 1 and 2 in TextSkupajDDV and TextBrezDDV, and 3 in
TextSkupajZDDV then your test will be

is "12" = "3"

wheras, if you take the value of the testbox, and cast it to a numeric
value, then you can force an addition, rather than a string concatenation.

....though I agree there's probably a simpler way to do it, but I was
following the 'teach a man to fish...' paradigm rather than the 'give the man
a fish' ...

:)

Philip

"MattShoreson" wrote:


All seems a little overengineered.
what about...

Private Function IzracunDDV()
IzracunDDV = True

If (TextSkupajDDV + TextBrezDDV= TextSkupajZDDV) Then
IzracunDDV = False
End If

End Function


--
MattShoreson
------------------------------------------------------------------------
MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472
View this thread: http://www.excelforum.com/showthread...hreadid=495452