We help IT Professionals succeed at work.

Function works in ASP, but Type Mismatch in VBScript??

Craig Lambie
Craig Lambie asked
Hi Experts,

I have a function that I can get to work fine in ASP, but when I try to call it from a script (vbscript) it doesn't work??
Error is Type Mismatch
If I remove the brackets it gives me Object Expected
If I add "" around the function variable same error

If you could let me know what the problem might be?

Thanks in advance...
<!--#include Virtual="/EUCApps/MoneyMarkets/includes/inc_functions.asp"-->
<!--#include Virtual="/EUCApps/MoneyMarkets/includes/inc_db_MMDesk_connect.asp"-->
response.write "Time Value " & Timevalue(now())
response.write "<br>" & Session("UserAccessLevel")
response.write "<br>" & Session("MMDeskAccessLevel")
response.write "<br>" & Session("PersonName")
response.write "<br>" & Session("Initials")
response.write "<br>" & Application("Environ")
'Response.write "<br>" & FormatDate(Now(), 1)
response.write "<br><br>" 
response.write fListIDtoItem(25)
response.write "<br><br>" 
response.write fListItemtoID("Confirmed")
response.write "<br><br><INPUT type=button value=click onclick=press()>"
<script language="VBScript" type="text/VBScript">
'msgbox fListIDtoItem("25")
function press()
msgbox fListIDtoItem (25)
end function
Function fListIDtoItem(strID)                                                                               
dim strSQLfunc
dim rsGetList                                                                                       
	Set rsGetList = CreateObject("ADODB.Recordset")                                                    
		strSQLfunc = "SELECT vchListItem " & _                                                                      
						 "FROM tblLists " & _                                                                           
						 "WHERE intListItemID=" & strID                                                               
			rsGetList.Open strSQLfunc, objSQLMMDeskConn, 0, 1
			If Not rsGetList.EOF then                                                                             
					fListIDtoItem = rsGetList.Fields("vchListItem").value                                              
					fListIDtoItem = false                                                                             
			end if                                                                                                
End Function

Open in new window

Watch Question

sure, the code when you call function is client script, (like javascript)
So you cant call the server script (your function)
Take a look at ajax to solve it


Thanks so much, missed that entirely...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.