Monday, June 20, 2011

Simple VBScript Commands

VBScript or who we know is the VBS is a computer language developed by Microsoft. Can be called Client Side, which is the script code can be viewed directly by the user. As with HTML and JavaScript scripts (JS).

The commands in VBScript, essentially the same as the commands (syntax) on the Visual Basic language support. Only, for VBScript does not require heavy software, rely on a Notepad.

1. Variable
          Variable (Var) is an empty place to fill a value that is saved to memory to use a program to perform an operation.

Example:


   Quote: Dim name, hobby
    name = "Ben"
    hobby = "write blog"
    MsgBox "Hello, My name is" & name & "hobby" & hobbies

Copy the script above into notepad, then save as type was changed to All Files so that files do not become the file. Txt

2. Constant
           Similarly, the variable, but the difference is the value of variables can still be changed at will. While Constant (Const) is always worth it.

Example:

    Quote: Const name = "Ben", hobby = "write blog"
    MsgBox "Hello, My name is" & name & "hobby" and address

Copy and paste the above Notepad and save the script in the same way. Save the file with the name Constant.vbs name

3. Control
          This structure is used for making a decision between several conditions. In the VBS there are two kinds of control structures, namely the If and Select Case

Example:

    Quote: Dim If
    If = InputBox ("Do you have a blog? [Y / N]:")
    If UCase (If) = "Y" Then
    MsgBox "You have a blog"
    ElseIf UCase (If) = "N" Then
    MsgBox "You do not have a blog"
    Else
    MsgBox "option simply 'Yes' or 'No' it!"
    End If

Copy and paste the above Notepad and save the script in the same way.
Save the file with the name Control.vbs name.

4. Loop (repeat)
           Looping or looping the loop in a process command. The loop in VBScript, among others: Do While ... Loop, For Next, For Each ... Next

Examples of Do While ... Loop Repetition:

    Quote: Dim re, x
    Do While x <3
    x = x + 1
    If x = 1 then re = "phase!"
    If x = 2 then re = "hip!"
    If x = 3 then re = "hup!"
    MsgBox re-
    Loop

Copy and paste the above Notepad and save the script in the same way. Save the file with the name DoWhile.vbs name


Example For Next loop:


    Quote: Dim re, x
    For x = 1 to 3
    If x = 1 then re = "phase!"
    If x = 2 then re = "hip!"
    If x = 3 then re = "hup!"
    MsgBox re-
    Next



Copy and paste the above Notepad and save the script in the same way. Save the file with the name ForNext.vbs name

Example For Each ... Next loop:

    Quote: Dim FSO, Drive, LihatDrive
    Set FSO = CreateObject ("Scripting.FileSystemObject")
    For Each Drive In FSO.Drives
    LihatDrive LihatDrive + = "Drive" + drive + "\"
    Next

    MsgBox "Drive in this computer is:" + LihatDrive


Copy and paste the above Notepad and save the script in the same way.
Save the file with the name ForEach.vbs name


5. Procedure
          VBScript there are two kinds of procedure. That procedure Sub and Function procedures. Sub procedure is a collection of sub-statement begins and ends with End Sub. Can take action without returning a value. Accepting the argument of a call (Call). In its use should be added to the sign ().

Example Sub procedure ():


    Quote: Call CobaSub ()
    Sub CobaSub ()
    MsgBox ("Examples of command sub procedure")
    End Sub

Copy and paste the above Notepad and save the script in the same way.
Save the file with the name SubProcedure.vbs name

Sub Function is a collection of statements begins and ends with End Function Function. Can take action, can also return a value. Can take orders call (Call). In its use should be added to the sign ().

Example Function procedure ():


    Quote: Function ContohFunction ()
    ContohFunction = "Ben"
    end Function
    MsgBox ("My Name" & ContohFunction ())

Copy and paste the above Notepad and save the script in the same way.
Save the file with the name FunctionProcedure.vbs name




NB: if there are errors in this thriead please om "justified because I still lay still have much to learn

No comments:

Post a Comment

thank you for commenting on our blogs