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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch, I don't see the problem... 1

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
I am not seeing why I get a type mismatch, if someone could point this out to me that would be a great help.


Microsoft VBScript runtime error '800a000d'
Type mismatch: 'ErrorMsg'

If NOT isEmpty(ErrorMsg(0)) then '## (Errors on this line)



<%

If Request.QueryString(&quot;action&quot;) = &quot;verify&quot; then

Dim ErrorMsg(5), messageTmp

first_name = Request.Form(&quot;first_name&quot;)
last_name = Request.Form(&quot;last_name&quot;)
address = Request.Form(&quot;address&quot;)
StrState = Request.Form(&quot;state&quot;)
Zip = Request.Form(&quot;zip&quot;)
int = Request.Form(&quot;int&quot;)


If isEmpty(first_name) then
ErrorMsg(0) = &quot;error&quot;
End if

If isEmpty(last_name) then
ErrorMsg(1) = &quot;error&quot;
End if

If isEmpty(address) then
ErrorMsg(2) = &quot;error&quot;
End if

If isEmpty(StrState) then
ErrorMsg(3) = &quot;error&quot;
End if

If isEmpty(Zip) then
ErrorMsg(4) = &quot;error&quot;
End if

If int = &quot;#&quot; then
ErrorMsg(5) = &quot;error&quot;
End if


For each x in ErrorMsg
If Not IsEmtpy(message) then
messageTmp = &quot;1&quot;
Else
messageTmp = &quot;0&quot;
End if
Next

If messageTmp = &quot;0&quot; then
'Put insert db code here..
'Redirect to thanks page..
End if


End if


%>

<% If NOT isEmpty(ErrorMsg(0)) then '## ERRORS HERE %>
<tr>
<td colspan=&quot;2&quot;>
<div align=&quot;center&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><b><font color=&quot;#FF0000&quot;>Please
provide a first name, and then re-submit the form.</font></b></font></div>
</td>
</tr>
<% End If %>
 
I believe the code to test for an error should be:

if errorMsg(0) <> &quot;&quot; then
doSomething
end if

IsEmpty is reserved for objects, your data is string data.

Your loop below may not work either:
************************************
For each x in ErrorMsg
If Not IsEmtpy(message) then
messageTmp = &quot;1&quot;
Else
messageTmp = &quot;0&quot;
End if
Next
************************************
Try
************************************
dim i

for i = 0 to 4
if errorMsg(i) <> &quot;&quot; then
doSomething
end if
next
************************************
Arrays are zero based, so errorMsg(5) ranges from 0 to 4.
errorMsg(0 to 5) will range from 0 to 5.

Hope that helps.

Jonathan Galpin
 
One quick addition concerning vb and arrays. They goofed and called this one a feature folks. Arrays in ASP (VB) actually are a bit off.
Dim myArray(5)

Can be looked at as an array from myArray(0) to myArray(4) OR myArray(1) to myArray(5)
Nifty, huh? A bit of extra functionality that Microsoft decided to provide? Perhaps, except that you can also consider that array to run from myArray(0) to myArray(5)

When Dim'ing an array in VB and ASP you are not defining the number of elements in the array (like just about every other language around) you are actually specifying an upper limit on a 0-based array, thus Dim myArray(5) is making a 6 element array that begins at 0 and has an upper bound of 5, thus the return amount from the UBound function.

Not a criticism, I didn't believe it the first few times I got errors trying to loop with array length, but apparently it is a feature.
-Tarwn
 
Thanks jlg, I scrated that way of doing it, but you did point out to me that you can't use isEmtpy for a string, so i gave you a star. And now I finally got it to work right.

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top