Wednesday, November 5, 2014

VBScript Important Statements

Option Explicit    ' To Force Develoer to declare the variable with DIM statment, if we don't declare the variables then the interpreter will throw and error.

Dim result,i,vartype,Msg,objw

result = " VB Version Number :" & ScriptEngine &" "& ScriptEngineMajorVersion &"."& ScriptEngineMinorVersion &"."& ScriptEngineBuildVersion & vbcrlf

Dim arr01(8)
arr01(0) = "711"
arr01(1) = "Raj Kumar"
arr01(2) = 60000    
arr01(3) = 4.25  
arr01(4) = #11/04/1981#
arr01(5) = #08.45 AM#  
arr01(6) = True
arr01(7) = Array ("One","Two","Three")



result = result &" Variable Type Name: " &vbcrlf


For each i in arr01

 vartype= typename(i) ' typename is to get the Type of the Variable

 result = result & "IsEmpty = "& isEmpty (i) & vbcrlf
 result = result & "IsNull = "& IsNull (i) & vbcrlf
 result = result & "IsObject = "& IsObject (i) & vbcrlf
 result = result & "IsNumeric = "& IsNumeric (i) & vbcrlf




 result = result & " Type  = "& vartype & vbcrlf & vbcrlf

Next

'MsgBox result

Msg =  "Vbscript" & vbCrLf & "Programming"
Set objW = CreateObject("Word.Application")
 objW.Visible = True


 With objW ' We can use With...End With... statement to select the default object for set of statments.
     .Documents.Add
     .Selection.TypeText result ' TypeText is to Type the text in document
     .Selection.WholeStory ' WholeStory is for select All
 End With