Multiplication by Null

Simple question...not having much luck finding an answer. (imagine that...LOL)

If a real number is multiplied by a null will there be a type mismatch error possibly generated?


integer=RoundToInt(real*null)



Your assistance is appreciated.

Resp,
John "delljohnb" Baugher

Comments

  • : If a real number is multiplied by a null will there be a type mismatch error possibly generated?
    :
    :
    : integer=RoundToInt(real*null)


    Hi!

    What happened when you tried it?



    [purple]Melissa[/purple]

  • : : If a real number is multiplied by a null will there be a type mismatch error possibly generated?
    : :
    : :
    : : integer=RoundToInt(real*null)
    :
    :
    : Hi!
    :
    : What happened when you tried it?
    :
    :
    :
    : [purple]Melissa[/purple]
    :
    :
    [grey]You would expect the answer of anything multiplied by null to be and rounded to an integer to be 0. But it will not be, it will not even produce an error, it will in fact be null. That is if you use the Int function, something that programmers seldom do as the CInt function is a better function, this however will give you an "Invalid use of Null" error.

    DjSpirit, if someone gives you Null cheescake, seek console in VB where Null & "cheesecake" will be "cheescake", thus make you entitled to such a baked delight.[/grey]
  • [b][red]This message was edited by delljohnb at 2005-4-14 9:57:48[/red][/b][hr]
    [b][red]This message was edited by delljohnb at 2005-4-14 9:56:28[/red][/b][hr]
    : : : If a real number is multiplied by a null will there be a type mismatch error possibly generated?
    : : :
    : : :
    : : : integer=RoundToInt(real*null)
    : :
    : :
    : : Hi!
    : :
    : : What happened when you tried it?
    : :
    : :
    : :
    : : [purple]Melissa[/purple]
    : :
    : :
    : [grey]You would expect the answer of anything multiplied by null to be and rounded to an integer to be 0. But it will not be, it will not even produce an error, it will in fact be null. That is if you use the Int function, something that programmers seldom do as the CInt function is a better function, this however will give you an "Invalid use of Null" error.
    :
    : DjSpirit, if someone gives you Null cheescake, seek console in VB where Null & "cheesecake" will be "cheescake", thus make you entitled to such a baked delight.[/grey]
    :


    'That is if you use the Int function, something that programmers seldom do as the CInt function is a better function, this however will give you an "Invalid use of Null" error.'

    Yep. That's what happened. I found a work around though...


    Function RoundToInt(byVal num)
    ' vbscript doesnt round in straightforward manner, hence the need for
    ' this workaround
    RoundToInt = round(num + 0.000001)
    End Function

    ********

    This was the original error I was getting.


    Microsoft VBScript runtime error '800a005e'
    Invalid use of Null: 'round'
    /tdutils/Ratings/Ratings_Global_Functions.asp, line 166



    Thanks for everyone's input. :-)



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories