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

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

Event-driven programming - windows programming, Event-Driven Programming: ...

Event-Driven Programming: The Event-driven programming allows the program to react to various inputs or events.   The action on a graphical component is an event. For il

Visual basic 2012, I am a beginner in Visual basic 2012 and making a data m...

I am a beginner in Visual basic 2012 and making a data management programme with visual basic 2012 as front end and MySql as back end. I want to filter data grid view table with Li

Imagelist, IMAGELIST The CImageList object is a collection of the same ...

IMAGELIST The CImageList object is a collection of the same sized images, all of which can be referred to by its index. The ImageList are used to proficiently manage the large

Windows programming, WINDOWS PROGRAMMING The Windows programming is a d...

WINDOWS PROGRAMMING The Windows programming is a developing application using the C and the native Win32 application interface (API) or C++ and the class libraries like Microso

Program to draw a rectangle shape , Create a project that draw a rectangle ...

Create a project that draw a rectangle shape which may be either (*) or (+) according to the selected radio button. The number of rows in the shape will be taken from the 1 st

The view - document view architecture, The View: The view is used for ...

The View: The view is used for visualising. For illustration, while performing word processing, the user works on a sequence of words which compose the text. If a user is perf

Create a visual basic application to play Hangman game, Create a Visual Bas...

Create a Visual Basic that allows a user to play a variation of Hangman. User Inputs The user types a letter into the textbox.   Functional Items 1. Read a

Application Deployment , I would like to know how to deploy a VB.NET Applic...

I would like to know how to deploy a VB.NET Application using SQL SERVER as a back-end database

Variable naming conventions, For reason of readability & consistency, emplo...

For reason of readability & consistency, employ the following prefixes along with descriptive names for variables in your VBScript code. S ub type Prefi

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