• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

VBScript Conditional..

Hello,

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
0
garethtnash
Asked:
garethtnash
  • 2
  • 2
1 Solution
 
GaryCommented:
And what does arrSurveyResults do?
0
 
garethtnashAuthor Commented:
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

RSSurveyResults.Close()
Set RSSurveyResults = Nothing
Set RSSurveyResults_cmd = Nothing
End if
'End RS SupplierSurveyBrands
%>

Open in new window

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

<% myNumber=int(arrSurveyResults(4,Rs)) %>
<% if (myNumber) >= 81 then %>
...
...
0
 
garethtnashAuthor Commented:
Thanks Gary
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now