Add Vbscript code to an html page, Visual Basic Programming

Assignment Help:

You can employ the SCRIPT element to add VBScript code to an HTML page.

The SCRIPT Tag

VBScript code is written inside paired SCRIPT tags.

For instance, a process to test a delivery date might appear as follows:

SCRIPT LANGUAGE="VBScript"

Function CanDeliver(Dt)

CanDeliver = (CDate(Dt) - Now()) > 2

End Function

SCRIPT

Beginning & ending SCRIPT tags surround the code. The LANGUAGE attribute specified the scripting language. You have to specify the language since browsers can use other scripting languages, like JavaScript. Notice that the CanDeliver function is embedded in comment tags. This prevents browsers which do not support the SCRIPT tag from displaying the code on the page.

As the example is a general function - it is not tied to any specific form control - you can comprise it in the HEAD section of the page as shown below:

 

Function CanDeliver(Dt)

CanDeliver = (CDate(Dt) - Now()) > 2

End Function

You can employ SCRIPT blocks anywhere in an HTML page. You can put them in the BODY and HEAD both sections. Though, you will probably desire to put all general-purpose scripting code in the HEAD section to keep all the code together. Keeping your code in the HEAD section make sure that all the code is read & decoded before it is required by any calls from inside the BODY section.

One distinguished exception to this rule is that you may want to provide inline scripting code within forms to respond to the events of objects in your form. For instance, you can embed scripting code to respond to a button click in a form as shown in Figure:

HTML

HEAD

TITLE Test Button EventsTITLE

HEAD

BODY

FORM NAME="Form1"

INPUT TYPE="Button" NAME="Button1" VALUE="Click"

SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript"

MsgBox "Button Pressed!"

This coding example will display a button on Web Page. While you click on the button it would display a message box stating "Button Pressed".

Mostly code will appear in either Sub or Function process and will be called only while the code you have written causes that function to execute. Though, you can write VBScript code outside process, but still in a SCRIPT block. This code is executed only once, while the HTML page loads. This let you to initialize data or dynamically alter the look of your Web page when it loads.


Related Discussions:- Add Vbscript code to an html page

Attributes, departmental store attributes

departmental store attributes

For next loop - vbscript, You can employ For...Next statements to run a blo...

You can employ For...Next statements to run a block of statements a specific number of times. For loops, employ a counter variable whose value is increased or decreased with each r

Assigning values to variables, Assigning Values to Variables Values are...

Assigning Values to Variables Values are assigned to variables creating an expression as follows: the variable is on the left side of the expression & the value you desire to a

Do until loop statement , Do Until Loop Statement: The statements with...

Do Until Loop Statement: The statements within the do...until loop block executes till the condition given in until become true. The working of do...until loop is elaborated w

Very Very Boards, This is from the book Programming in Visual Basic 2010 by...

This is from the book Programming in Visual Basic 2010 by Julia Case Bradley and Anita C. Millspaugh. The assignment is located in Chapter 3 on page 154. Before I type it in, I wou

Create an application that calculates customer monthly bill, In this assign...

In this assignment, you will create an application that calculates and displays a customer's monthly cable bill. Your interface should look like this: Requirements:

Dynamic link library - database applications, DYNAMIC LINK LIBRARY   T...

DYNAMIC LINK LIBRARY   The dynamic link library (dll) permits one copy of a function to be shared among some parallel executing programs. The dll is a file that contains a num

Illustration of ccolordialog, ILLUSTRATION OF CCOLORDIALOG The construc...

ILLUSTRATION OF CCOLORDIALOG The constructor of the CColorDialog takes the initial parameter as the default color and the next parameter specifies how much the dialog is displa

Variant subtypes, Beyond the simple string or numeric classifications, Vari...

Beyond the simple string or numeric classifications, Variant can make added distinctions regarding the specific nature of numeric information. For instance, you can have numeric in

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd