VBScript Conditional..

Posted on 2012-09-05
Last Modified: 2012-09-06

Please can you let me know what is wrong with the code below -

<% if (arrSurveyResults(4,Rs)) >= 81 then %>
<%=arrSurveyResults(4,Rs)%> Exceptional
<% elseif arrSurveyResults(4,Rs) >= 61 then %>
<%=arrSurveyResults(4,Rs)%> Excellent
<% elseif arrSurveyResults(4,Rs) >= 41 then %>
<%=arrSurveyResults(4,Rs)%> Above Average
<% elseif arrSurveyResults(4,Rs) >= 21 then %>
<%=arrSurveyResults(4,Rs)%> Average
<% else %>
<%=arrSurveyResults(4,Rs)%> Below Average
<%End if%>

Open in new window

I get Type mismatch error

The <%=arrSurveyResults(4,Rs)%> variable is always a number between 0 and 100.

Thank you
Question by:garethtnash
    LVL 58

    Expert Comment

    And what does arrSurveyResults do?

    Author Comment

    it builds an array, which returns numbers --
    'RS Supplier Survey  only run if SurveyStarted = "N"
    IF StockedBrandStatus = 0 AND NotStockedStatus = 0 then
    Dim RSSurveyResults__MMColParam
    RSSurveyResults__MMColParam = NULL
    If (Session("UID") <> "") Then 
      RSSurveyResults__MMColParam = Session("UID")
    End If
    Dim RSSurveyResults__MMColParam2
    RSSurveyResults__MMColParam2 = NULL
    If (SupplierSurvey <> "") Then 
      RSSurveyResults__MMColParam2 = SupplierSurvey
    End If
    Dim RSSurveyResults
    Dim RSSurveyResults_cmd
    Dim RSSurveyResults_numRows
    Set RSSurveyResults_cmd = Server.CreateObject ("ADODB.Command")
    RSSurveyResults_cmd.ActiveConnection = MM_GolfConnection_STRING
    RSSurveyResults_cmd.CommandText = "SELECT  S.[ID], B.Name ,[CYearStockist] ,ISNULL([CYearNStockistWhy],0)CYearNStockistWhy ,ISNULL(SUM([Saleability] + [Quality] + [Availability] + [Delivery] + [Returns] + [RetailPrice] + [ServiceSupport] + [Rep] + [Accounts] + [CreditControl])*2, 0.00) as Score ,[NextYearTrade] ,[NoTradeWhy] FROM [dbo].[SupplierSurveyInput] S inner join dbo.Brand B on B.ID = S.BrandID Where PartnerID = ? AND S.SupplierSurveyID = ? GROUP BY S.ID, B.Name, CYearStockist, CYearNStockistWhy, NextYearTrade, NoTradeWhy order by Score desc" 
    RSSurveyResults_cmd.Prepared = true
    RSSurveyResults_cmd.Parameters.Append RSSurveyResults_cmd.CreateParameter("param1", 5, 1, -1, RSSurveyResults__MMColParam) ' adDouble
    RSSurveyResults_cmd.Parameters.Append RSSurveyResults_cmd.CreateParameter("param2", 5, 1, -1, RSSurveyResults__MMColParam2) ' adDouble
    Set RSSurveyResults = RSSurveyResults_cmd.Execute
    RSSurveyResults_numRows = 0
    If Not RSSurveyResults.Eof then
    dim arrSurveyResults
    arrSurveyResults = RSSurveyResults.GetRows()
    End if
    Set RSSurveyResults = Nothing
    Set RSSurveyResults_cmd = Nothing
    End if
    'End RS SupplierSurveyBrands

    Open in new window

    LVL 58

    Accepted Solution

    The field must be a string, just convert it to a number

    <% myNumber=int(arrSurveyResults(4,Rs)) %>
    <% if (myNumber) >= 81 then %>

    Author Closing Comment

    Thanks Gary

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
    Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now