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

Data types - visual basic, DATA TYPES   The different primitive data t...

DATA TYPES   The different primitive data types are Boolean, Char, Byte, Date, Decimal, Uinteger, Double, Integer, Long, Sbyte, Short, Single, String, Ulong & Ushort. To decla

Sub and function procedures in code, In your code A, Function has to always...

In your code A, Function has to always be used on the right side of a variable assignment or in an expression. For illustration: Temp = Celsius(fDegrees) or Msg Box "The C

Mr, want a visual basic code on Hungarian method

want a visual basic code on Hungarian method

Homework Help, Creating an application that will calculate the cost of a ca...

Creating an application that will calculate the cost of a car rental based on the number of days that the car is rented. the cost of the car rental includes the cost of the car its

Properties - intrinsic control, Properties: Every control has a defaul...

Properties: Every control has a default property related with it. The default property does not require to be named when you are functioning. The control Check box as value

Programming, i have connected my visual basic 2010 express in ports and use...

i have connected my visual basic 2010 express in ports and use it to send sms but it failed... now my teacher said that i have to use my LAN not port to send it instead..... please

Visual interface based on visual patterns , Visual Interface  Based On Vis...

Visual Interface  Based On Visual Patterns: The visual user interface should create recognizable patterns and text will be used for differentiating the objects with similar pa

Check box - visual basic, Check Box: The check box control takes the v...

Check Box: The check box control takes the value as on or off or grayed. The grayed one is neither on nor off. The user can transform the setting of the grayed check box.

Help context property, Sets or returns context ID for topic in Help File. I...

Sets or returns context ID for topic in Help File. If Help file is indicated in the VBScript Err Object HelpFile Property, the HelpContext property is utilized to display automatic

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