I have a framework written in VBScript. Inside some function in this framework, a parameter of the function is checked for Nothing in an If statement and then some actions are executed.
Code that uses the framework is written in JavaScript. So I need to pass Nothing to the function to perform some actions. In Internet Explorer 8 and earlier versions, the following approach worked:
<script type="text/vbscript">
Function Test(val)
If (IsNull(val)) Then
Test = "Null"
ElseIf (IsObject(val)) Then
If (val Is Nothing) Then
Test = "Nothing"
End If
End If
End Function
Dim jsNothing
Set jsNothing = Nothing
msgBox(Test(jsNothing))
msgBox(Test(Null))
</script>
<script type="text/javascript">
alert(Test(jsNothing));
</script>
In Internet Explorer before version 9, the output will: Nothing, Null, Nothing.
In Internet Explorer 9: Nothing, Null, Null.
How can I pass Nothing from JavaScript to VBScript in Internet Explorer 9?
There is an example of a framework function. I can not change it, because it is widely used in application.
Function ExampleFunction(val)
If (val Is Nothing) Then
ExampleFunction = 1
Else
ExampleFunction = 0
End If
End Function
IsObject(val) And val Is Nothing
will still result in an error. You'll have to split it into a nested If. – Parthinia