Results 1 to 7 of 7

Thread: How to add VBScript code in a page

  1. #1
    Join Date
    Jul 2010
    Posts
    30

    How to add VBScript code in a page

    I am trying to insert the VBScript code in page but not able to do so. Let me tell you that I have recently started learning about the VBScript code, so not having much knowledge about it. I am sure that you members will give some help regarding my problem. The only thing I am want to know is how to add VBScript code in a page? Also it would be better if you tell me about the variables that are used while doing the coding in VBScript. Any other information would be grateful that are concerned with the topic.

  2. #2
    Join Date
    Jan 2009
    Posts
    143

    Re: How to add VBScript code in a page

    In HTML, there is <script> tag that is used to include code in a scripting language. In the case of VBScript syntax is:
    Code:
    <script language="VBScript"> 
    <! - 
    VBScript ...... ..... 
    -> 
    </ Script>
    When the HTML page arrives at the browser, it interprets the code included in tag <script>. Through the Language attribute indicates the scripting language used. The VBScript code is placed between the comment tags <! - ->, So the code is not displayed in browsers that do not support <script>. If you are new to VBScript, the question that might arise in your mind is where to put this code? Let me tell you that, it totally depends on its function. It can be inserted in the HEAD or BODY. A script that displays a message, sure to be seen in BODY.

  3. #3
    Join Date
    Jan 2006
    Posts
    211

    Re: How to add VBScript code in a page

    I think that "Timothi" has mentioned the correct thing that every learner of VBScript should know this. I would like to provide some coding by which you can get the concept easily. Let's start with a page that displays the classic massage "Hello World." You must know the command that displays a message: document.write.
    Code:
    <html> 
    <head> 
    <title> an example </ title> 
    </ Head> 
    <body> 
    
    <script language="VBScript"> 
    <! - 
    document.write "Hello World" 
    //--> 
    </ Script> 
    
    
    </ Body> 
    </ Html>

  4. #4
    Join Date
    Dec 2008
    Posts
    202

    Re: How to add VBScript code in a page

    Surely if we talk about HTML could discuss hours to decide whether it is a better editor or another, but for more sophisticated languages such as VBScript editor that does not give a great help, and the program that makes the difference. Notes From the Block to Front Page or DreamWeaver, the differences are smaller with regard to the VBScript code. The only editor that really helps to plan is Visual InterDev. This editor, in addition to color code depending on the type of education helps the programmer when writing code with intelligent menu, as shown below :
    Screenshot of Visual InterDev

    In some versions of Office 2000 installs a scaled-down version of this Editor that is located on the Hard Disk:
    C: Visual ProgrammingMicrosoft StudioCommonIDEIDE98mse.exe

  5. #5
    Join Date
    Dec 2008
    Posts
    161

    Re: How to add VBScript code in a page

    Whatever editor you use the outcome of the first suit will be written in the browser: "Hello World" Let's try to embellish it: let the words Red Army, and in Arial Bold. Here are two ways to do this :
    Code:
    <html> 
    <head> 
    <title> 1A Example </ title> 
    </ Head> 
    <body> 
    <font face="Arial" color=#ff0000> 
    <b> 
    
    <script language="VBScript"> 
    <! - 
    document.write "Hello World" 
    //--> 
    </ Script> 
    
    </ B> 
    </ Font> 
    </ Body> 
    </ Html>
    or ..
    Code:
    <html> 
    <head> 
    <title> 1B Example </ title> 
    </ Head> 
    <body> 
    <script language="VBScript"> 
    <! - 
    document.write "<font face=""Arial"" color=#ff0000> <b>" 
    documnet.write "Hello World" 
    document.write "</ b> </ font>" 
    //--> 
    </ Script> 
    
    </ Body> 
    </ Html>
    Interestingly, the two programs do the same thing, but while the former is a VBScript code embedded in HTML code, the second one has an HTML code in the VBScript code inside another HTML. This makes us understand that the browser interprets the code first and then the VBScript HTML.

  6. #6
    Join Date
    Apr 2008
    Posts
    193

    Re: How to add VBScript code in a page

    The VBScript is a derivative of Visual Basic, and variable behave much the same way. To declare them using the Dim statement example :
    Code:
    Dim variable1 
    Dim variable2 
    etc..
    Or
    Code:
    Dim variable1, variable2, etc..
    Those accustomed to other languages knows that declaring a variable must also define the type, that is if will contain a number, string, date, etc.. In VBScript, this distinction does not exist: it is not necessary to declare the type of variables. The management of a number or a string is assigned VBScript interpreter. This makes it much easier to program, but be careful, as in the following example:
    Code:
    <script language="VBScript"> 
    <! - 
    dim a, b, c 
    a = inputbox ("First Number:") 
    b = inputbox ("Second Number") 
    c = a + b 
    document.write c 
    //--> 
    </ Script>
    In the above example, assign values to variables a and b through the InputBox, that dialog boxes that prompt the user to enter a value. If I assign the value 3 and 5, the first second, it is expected that the line "document.write c" print the value of 8 and 35 show instead.

  7. #7
    Join Date
    Mar 2008
    Posts
    232

    Re: How to add VBScript code in a page

    If I assign the value 3 and 5, the first second, it is expected that the line "document.write c" print the value of 8 and 35 show instead.
    This is because a and b are interpreted as strings, and the + sign instead of the sum concatenate two strings. To resolve this problem it is necessary to convert from string to numeric variables. The types and should not be declared, but there are:
    • Boolean - May contain True or False.
    • Byte - Contains an integer between 0 and 255.
    • Integer - Contains an integer between -32,768 and 32,767.
    • Currency - Contains a value between -922,337,203,685,477.5808 and 922,337,203,685,477.5807.
    • Long - Contains an integer between -2,147,483,648 to 2,147,483,647.
    • Single - It contains a number in single-precision floating-point between -3.402823 3.402823 E38 and E38
    • Double - It contains a number in double precision floating-point between -1.79769313486232 1.79769313486232 E308 and E308
    • Date - It contains a number representing a date between January 1 and December 31 of the 100 of 9999.
    • String - Contains a string of variable length consisting of a maximum of about 2 billion characters.
    • Object - Contains an object.

Similar Threads

  1. Reusing JSF Page Code
    By Lian in forum Software Development
    Replies: 4
    Last Post: 22-07-2010, 06:21 AM
  2. How to interaction VBScript and JScript in ASP page
    By Lawford in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 04:50 AM
  3. Problems Inserting a VBScript into HTML Page?
    By Viensterrr in forum Software Development
    Replies: 4
    Last Post: 29-01-2010, 04:58 PM
  4. My VBScript code not working properly
    By - Empty Shell - in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 10:32 PM
  5. Replies: 2
    Last Post: 14-09-2005, 03:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,664,191.11142 seconds with 17 queries