The lowest value?

Hi guys

My issue seems straight forward enough but I can’t seem to find a solution anywhere so I fear it’s no possible. Anyway, here goes…

I basically have the following script (classic asp)

width = “200”
height = “400”

What I need is for my page to display which of the two, width or height, has the lowest value. The values will dynamically change from time to time dependant on other factor. So, in the above example it would be the width, with a value of “200”, is the lowest. However, what I need to display on my page is the word “height” or “width” on my page. So, the display on my page, for the above example, would simply read:


Is this at all possible? and if so, then how it is done in classic asp? Any help would be fully appreciated.

Best regards

Rod from the UK

You need the equivalent of the IIF functionality. Since vbScript doesn’t have this by default, you’ll need to create one. I used something like this (it’s been about 5+ years since I’ve done asp, so forgive any syntax errors…

Please forgive the color syntax…it should be right, but discourse doesn’t do vbscript highlighting…

function IIF (condition, TrueResponse, FalseResponse)
   if condition then
      IIF = TrueResponse
     IIF = FalseResponse
   end if
end function

' Usage
strDisplay = IIF(width > height, width & " WIDTH", height & " HEIGHT")

Excellent - thanks Dave

Best regards

Rod from the UK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.