hackrishna Posted December 26, 2011 Report Posted December 26, 2011 1 Can we pass optional argument to function in VBScript? Ans: Yes, We can pass optional argument to VBScript functions.We can use optional argument in VBScript by specifying optional keyword. 2 How you define parametrization in VBScript? Ans: Parametrization is useful when we want to change object's parameters in accordance with a mathematical rule, or data from a file. We can say that Parametrization is the best way to protect your database from SQL injection attacks. 3 Define subtypes of data that a Variant data type in VBScript? Ans: Subtypes of data that a Variant data type in VBScript are given below: Byte - Between 0 to 255 String - Character strings Integer - Between -32,768 and 32,767 Long - Between (-2,147,483,648 and 2,147,483,647) Double - Extremely large numbers with decimal points Empty - The value that a variant holds before being used Error - An error number Null - No valid data Single - Large numbers with decimal points Currency- Monetary values Date - Date and time Object - Objects Boolean - True and False 4 How you define Option Explicit in VBScript? Ans: If you want to use Option Explicit in VBScript you should have to declare all variables using the Dim, Private, Public, or ReDim statements. Using Option Explicit to avoid incorrect typing the name of an existing variable or to avoid confusion in code where the scope of the variable is undefined. 5 How Sub Procedures and Function Procedures are differ in VBScript? Ans: VBScript support two types of procedures. These are Sub Procedures and Function Procedures The main difference b/w Sub Procedures and Function Procedures are given below: 1.In case of Sub Procedures we write series of VBScript statements inside the Sub and End Sub statement Where as in Function Procedures we write series of VBScript statements inside the Function and End. 2.Sub Procedures does not return any value where as Function Procedures return a value. 3.Procedures has two build-in VB Script functions these are MsgBox and InputBox. Example: Suppose you want to do a calculation.Then Using Sub Procedures we can displays the results of a calculation based on that information. Sub ConvertTemp() temp = InputBox("Enter temperature in degrees F.", 1) MsgBox "Temperature is " & Celsius(temp) & " degrees C." End Sub And Using function procedure we performed the calculation using VBScript. Function Celsius(fDegrees) Celsius = (fDegrees - 32) * 5 / 9 End Function 6 Define Tristate constants in VB Script? Ans: We can allow formatting of numbers by using Tristate constants with functions. Tristate functions are used to reflect and represent the values any where in the code.Without defining Tristate constant it can be used with Vb Script. 7 How you define ADODB.Stream class? Ans: We can use ADODB.Stream class as string builder. Because using VBScript string concatenation we can frequent memory allocation features.So,It is very costly.ADODB.Stream class provide us Binary file and memory I/O operation.Using this we can convert bytes into string etc. 8 How we use scrrun.dll in JavaScript? Ans: scrrun.dll(Scripting Runtime library) is an important library which is used for the functioning of Visual basic script.We can improve some functionality like that File management, text operations and file modification features. 9 Explain the functionality of VB Script? Ans: Using Active X technology we give much more functionality to VB Script.VB provide us sub routines, functions, string manipulation, data/time , error handling etc. We can increase the functionality of VB by using language like that ASP. 10 Define some use of VB Script? Ans: As per functionality we can say that VB Script acts same to Java Script.But VB Script is only compatible with internet explorer. VB Script act with Document object model.We can use Visual basic script used for server side processing with ASP. 11 Can VBScript can directly run on users system with Windows as OS? Ans: Yes, VBScript can directly run on users system with Windows as OS.I explain with an example The running of VB Script is by utilizing Windows Script Host environment.In this input enter through GUI(Graphical User Interface) and output receives from Wscript.exe .It can be raised by Cscript.exe from command line. 12 What type of loops used in VBScript? Ans: When you want to execute same blocks of code a perticular number of times than we use looping. VBScript provide us four types of looping statements these are: 1.For..Next statement 2.For Each..Next statement 3.Do..Loop statement 4.While..Wend statement 1.For..Next statement: When you already know about number of repetitions then we use For..Next statement. Example: For i=1 to 5 Write some code here Next Above program will display output till value of i is 1,2,3,4,5, We use 'Step' keyword you want to increase or decrease the value of variable. Below,When loop repeated it increase the value of three steps each time. Example: For i=3 To 15 Step 3 Write some code here Next Below,When loop repeated it decrease the value of two steps each time. Example: For i=15 To 3 Step -3 Write some code here Next If you want to exit For..next statement than we have to use Exit For Keyword. 2.For Each..Next statement: Using this we can execute a block of code for each element of an array. Example: dim friends(3) friends(0)="Tom" friends(1)="Jack" friends(2)="Sam" friends(3)="Robert" For Each i in friends document.write(i & "<br />") Next 3.Do..Loop statement: We use this loop when we don't know how many times a loop will execute. And repeat the block of code till it is true. Loop will executed atleast one time whenever condition is true or false. Example: Do While i>14 Write some code here Loop If value of i is less than 14 loop doesn't executed. Do Write some code here Loop While i>14 Above,loop will executed atleast one time whenever condition is false(when value of i is less than 14.And it will repeated codes till condition is true. Until Keyword: Using Until,we can check the condition if it is true than code will not executed. Example: Do Until i=5 Write some code here Loop It will executed until the value of i is 5. Example: Do Write some code here Loop Until i=5 It will execute code atleast one time.And further execute until the condition is true(i=5). We can exit from do..loop statement after using Do exit keyword. Example: Do Until i=5 i=i-1 If i<5 Then Exit Do Loop Above, loop is executed when it is different from 5 till it becomes greater than 5. 4.While..Wend statement: We don't use this or else use do..loop statement. 13 What conditional statement do we use in VBScript? Ans: Conditional statements that we use in VBScript are given below: 1.if statement 2.if..than..else statement 3.if..than..else if statement 4.select case statement 1.if statement: In if statement we execute a statement when some condition is true. Example: if i=8 Then msgbox "Welcome". This code will execute only one time. 2.if..then..else statement: Used when we want to execute more than one statement when some condition is true. Example: if i=8 Then msgbox "Welcome" i = i+1 end If In the above code we can execute multiple statements when condition is true or using else can execute statement the condition is false. Like that, if i=8 then msgbox "Welcome" else msgbox "Wait" end If If condition is true(i=8) it will display Welcome otherwise Wait. 3.if..then..else if statement: We can use this type of statements when we want to execute more than one block of code.It can execute more than one statement whenever our condition is true or false. Example: if name="Abhi" then msgbox "Welcome Abhi!" elseif name="Jaleese" then msgbox "Welcome Jaleese!" elseif name="Shrish" then msgbox "Welcome Shrish!" else msgbox "R4R Welcomes You!" end If 3.select case statements: using select statement we can execute more than one blocks of code. Example: select case name case "Abhi" msgbox "Welcome Abhi!" case "Jaleese" msgbox "Welcome Jaleese!" case "Shrish" msgbox "Welcome Shrish!" case Else msgbox "R4R Welcomes you!" end select 14 How to call a Sub or Function Procedure? Ans: You can call the function like that, name = name(); And we can return the stored value like that, msgbox "Welcome: " & name() To call the Sub procedure by using Call statement. Like that, Call MyProc(argument) or you can neglect the Call statement,Like that, MyProc argument 15 What is the VBScript Procedure? Ans: In VBScript there are two types of procedure available.They are Sub Procedure and Function Procedure. 1.Sub Procedure: In this series of statement are closed b/w the Sub and End Sub statements.It may be Sub procedure performs actions without returning any value.We can passed argument when we called this procedure.Their is no mandatory to pass argument b/w the parentheses. Syntax: Sub firstsub() Write some statements here End Sub 'OR' Sub firstsub(arg1,arg2) Write some statements here End Sub 2.Functional Procedure: In this series of statement must enclosed b/w the Function and End Function statements.When it perform any action may return a value.We can passed arguments when we called the procedure.Their is no mandatory to pass argument b/w the parenthesis.When we assign value to variable then it returns that value. Syntax: Function firstfunction() Write some statements here firstfunction=give some value End Function 'OR' Function firstfunction(arg1,arg2) Write some statements here firstfunction=give some value End Function 16 How you define Array Variable in VBScript? Ans: When we create any Array variable then in this a variable can store more than one value.We declare an array variable using parenthesis(). Example: Here I declare a variable name. dim names(3) In this we declare an array variable name that can store only four values.We can assign value to each element of variable like that, names(0)="Abhi" names(1)="Sudd" names(2)="Shrish" names(3)="Jaeleese" Now, we can select particular name entry from name variable to any other variable like that, friend=names(2) 17 What do you understand from Lifetime of Variables? Ans: Existence period of variable are told as its Lifetime. When we declare a variable with a unique procedure then this procedure perform associated task and exits then the variable hold by this procedure will get destroyed.It may happen when Variable with same name exists with different procedure.Because each variable perform their specific task.These types of variables are called Local variable. 18 How to declare and assign values to variable in VBScript? Ans: We can declare Dim,Public or Private statement in VBSCript like that. dim name name=Give some value Now,We created a variable named 'name'. When you declare variable with statements(Dim, Public or Private) then we introduce 'option explicit' statement before declaring the script.Like: option explicit dim name name=give some value Example: name="Abhi" x=50 19 What is a variable? Ans: We use variable to store information or values. We can change value of variable during the script. In VBScript all variables are type of variant so each variable can store different type of data. You have to keep some rules in mind when you create any variable. 1.Variable name can't more than 255 characters. 2.Variable name must start with a letter. 3.Variable name doesn't contain a period(.). 20 In HTML where we insert VBScript? Ans: We can use Script in web pages by two ways. First we can set script to perform their specific task when the web page loads. Second is that script will perform their associated task when used click or trigger an event. When we insert script in the head section: Script of head is executed when they are called or when an event is trigger in head section. Example: <html> <head> <script type="text/vbscript"> Write some statements here </script> </head> When we insert script in the body section: In this only those script are executed that are placed in body section. Example: <html> <head> </head> <body> <script type="text/vbscript"> Write some statements here </script> </body> When we insert script in both body and head section: You can insert script in both body and head section together. Example: <html> <head> <script type="text/vbscript"> Write some statements here </script> </head> <body> <script type="text/vbscript"> Write some statements here </script> </body> Credits: R4R Quote
iAjayIND Posted August 7, 2013 Report Posted August 7, 2013 i will die if interviewee will ask me this questions . anyways, thanks for this ... +1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.