Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch cint error

Status
Not open for further replies.

mtrasp

Programmer
Jun 15, 2009
35
US
Hi
i am getting mismatch type error .please help me

how can i write if condition to satisfy all the conditions

if the releasename is 15.16 in asp page then array(0)=15 and array(1)=16 is not showing any error but

if the releasename is 15.12win7 or 15.win7 it is showing error how can i write if condition to get into the loop with out showing any error
just i need to enter into loop whether releasename is 15.16 ,15.12win7 or 15.win7

here is the code
<% array = Split(rs.Fields("ReleaseName").Value, ".")

If CInt(array(0)) >= 15 And Cint(array(1)) >= 16 then

<tr>

<th> Version</th>
<td>
<% If rs.Fields("Defaultversion") = rs.Fields("Mediaversion") Then %>
<font color="green">(Default)</font>
<% Else %>
&nbsp;<font color="red">(Customized)</font>
<% End If %>
</td>

</tr>
<% End If %>
 
CInt() expects a numeric parameter, and you get a type mismatch if your parameter is not numeric. One option is to use the IsNumeric() function to test that array(0) and array(1) are in fact numeric, before using CInt().

If you know that your only possible values for ReleaseName are 15.16, 15.12win7, and 15.win7, just compare the text without the conversion:
Code:
If rs.Fields("ReleaseName").Value = "15.16" Or _
   rs.Fields("ReleaseName").Value = "15.12win7" Or _
   rs.Fields("ReleaseName").Value = "15.win7" Then
   
    ...
End If

Although, if you are dealing with version numbers, you may in fact want a numeric comparison... so you would need a way to cope with the "win7", which is not numeric.
 
I'm glad to see that you got an answer here as well as at aspfree.com where you just posted the same question.

 
You could take the isNumeric function as recommended by guitarzan and place it in a function to strip any non-numeric character, or rebuilt the input and stop when a non-numeric character is found (as demonstrated here)

Code:
<% 
function stripChars(strInput)
	for i = 1 to len(strInput)
		character = mid(strInput,i,1)
		if isNumeric(character) or character = "." then
			str = str & character
		else
			exit for
		end if
	next
	stripChars  = str
end function
version = "15.17win7"
if not isNumeric(version) then version = stripChars(version)
ra = split(version ,".")
%>
Val 1 Check: <%=ra(0)%><br />
Val 2 Check: <%=ra(1)%><br />

That returns a 15 and 17, which will both work with cint(). If the value being checked is 15.win7, you will get an error as you'll be trying to pass an empty value to cint(), but I'm sure you can figure out how to handle that...

Good luck

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Hi
Thank you for your reply. there are many values are coming into this page. those values are only integers so no problem i am getting error with 15.12win7 and 15.win7.
if relase name is 15.12win7 i am using If CInt(array(0)) >= 15 And cint(left(array(1),2))>=16 it is working fine . when the release name is 15.win7 i am getting error

can i follow this one

IIF(IsNumeric(array(1)),cint(left(array(1),2))>=16,"win7")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top