Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Visual Basic Expert

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.

Visual Basic, Programming

  • Category:- Visual Basic
  • Reference No.:- M9620982

Have any Question?


Related Questions in Visual Basic

Assignment virtual storeuse the concepts and scenario from

Assignment: Virtual Store Use the concepts and scenario from Assignment 1 to help "Your" Virtual Business to increase the functionality of its online shopping cart. When a customer checks out, the shopping cart must stor ...

Pitch amp game design documentthe assignment is about

Pitch & Game Design Document The assignment is about educational driver for teenagers Assignment Brief: In groups you will: - present a pitch and produce a one sheet - provide a demonstration of your game - produce a hig ...

Please show how to do the belowvisual basic net application

Please show how to do the below: Visual Basic .NET Application - Coding Exercise 1 (Exercise 13, Zak, 2016, p. 347) For this coding exercise, write the Visual Basic code for a pretest loop that uses an Integer variable n ...

Assignment frans virtual fruit standfrans virtual fruit

Assignment: Fran's Virtual Fruit Stand Fran's Virtual Fruit Stand is an online store that sells several types of dried fruit. Based on the needs of Fran's Virtual Fruit stand, you must design a flowchart using Visual Log ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As