EzDevInfo.com

vbscript interview questions

Top vbscript frequently asked interview questions

What is the difference between dim and set in vba

Pardon me as am a newbie in VBA, VB.NET.

Sometimes I use

Dim r as Range
r = Range("A1")

Other times I use

Set r = Range("A1")

What is the difference? And when should I use what?


Source: (StackOverflow)

How do I include a common file in VBScript (similar to C #include)?

VBScript doesn't appear to have a way to include a common file of functions.

Is there a way to achieve this?


Source: (StackOverflow)

Advertisements

Can Windows' built-in ZIP compression be scripted?

Is the ZIP compression that is built into Windows XP/Vista/2003/2008 able to be scripted at all? What executable would I have to call from a BAT/CMD file? or is it possible to do it with VBScript?

I realize that this is possible using WinZip, 7-Zip and other external applications, but I'm looking for something that requires no external applications to be installed.


Source: (StackOverflow)

How do you keep debug code out of production?

It happens to the best of us.

alt text

Particularly when dealing with languages without built in debugging capabilities such as breakpoints and watched variables, these bugs bite developers. Debugging code, alerts and Response.Writes, show up in production code.

How do you separate debugging concerns from functional code in javascript, php, or vbscript? How do you ensure those debugging changes never enter production environments?


Source: (StackOverflow)

How do I return an exit code from a VBScript console application

I Have an old vbs script file being kicked off by an AutoSys job. Can I, and how do I, return an int return value to indicate success or failure?


Source: (StackOverflow)

VBScript -- Using error handling

I want to use VBScript to catch errors and log them (ie on error "log something") then resume the next line of the script.

For example,

On Error Resume Next
'Do Step 1
'Do Step 2
'Do Step 3

When an error occurs on step 1, I want it to log that error (or perform other custom functions with it) then resume at step 2. Is this possible? and how can I implement it?

EDIT: Can I do something like this?

On Error Resume myErrCatch
'Do step 1
'Do step 2
'Do step 3

myErrCatch:
'log error
Resume Next

Source: (StackOverflow)

Using command line arguments in VBscript

How can I pass and access command line arguments in VBscript?


Source: (StackOverflow)

HTTP GET in VBS

Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.

Thanks.


Source: (StackOverflow)

How to set delay in vbscript

How to set delay in vbscript?

WScript.Sleep(100) does not work on Windows XP, Vista.


Source: (StackOverflow)

How does garbage collection work in JavaScript?

How does garbage collection work in JavaScript? Is it similar to .NET garbage collection? And is it because the implementation of garbage collection in VBScript is bad that people avoided it and established a preference for JavaScript as their standard client-side language?


Source: (StackOverflow)

Getting the Username from the HKEY_USERS values

Is there a way to connect between the values under HKEY_USERS to the actual username?
I saw some similar questions, but most (if not all) talks about C# code, and my need is in VBScript.


Source: (StackOverflow)

What is the best way to iterate through an array in Classic Asp VBScript?

In the code below

For i = LBound(arr) To UBound(arr)

What is the point in asking using LBound? Surely that is always 0.


Source: (StackOverflow)

What is your favorite VBScript Editor? [closed]

I currently use notepad++ for writing/editing VBScipts, but I am looking for something new (and also free). Anybody have a favorite?

I don't have a problem with notepad++; in fact I really like it and I use it a lot, I just want to see what other options are available. I would like to find something that has more of an IDE feel to it, but also supports multiple languages.

Edit:
I guess I underestimated notepad++, or I just want too much for nothing, either way I will be sticking with notepad++.


Source: (StackOverflow)

Pass Nothing from Javascript to VBScript in IE9

I have a framework written in VBScript. Inside some function in this framework parameter of the function is checked for Nothing in If statement and then some actions executed. Code that uses framework written in Javascript. So I need to pass Nothing to function to perform some actions. In IE8 and earlier versions worked next approach:

<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 IE < 9 output will: Nothing, Null, Nothing.

In IE9: Nothing, Null, Null.

How can I pass Nothing from Javascript to VBScript in IE9?

Sorry, I know it's ugly, but I'm trapped. And hate VBScript.

edit: There is an example of 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

Update

Quitted job. Found a better one.


Source: (StackOverflow)

vbscript output to console

What is the command or the quickest way to output results to console using vbscript?


Source: (StackOverflow)