Search In Site

03 July, 2013

HTML Document: Basic Tags And Elements


Creating an HTML document is easy. To begin coding HTML you need only two things: a simple-text editor and a web browser. Notepad is the most basic of simple-text editors and you will probably code a fair amount of HTML with it. You can use our HTML Online Editor to learn HTML. Here are the simple steps to create a baisc HTML document:

  •  Open Notepad or another text editor.
  •  At the top of the page type <html>.
  •  On the next line, indent five spaces and now add the opening header tag: <head>.
  •  On the next line, indent ten spaces and type <title> </title>.
  •  Go to the next line, indent five spaces from the margin and insert the closing header tag: </head>.
  •  Five spaces in from the margin on the next line, type<body>.
  •  Now drop down another line and type the closing tag right below its mate: </body>.
  •  Finally, go to the next line and type </html>.
  •  In the File menu, choose Save As.
  •  In the Save as Type option box, choose All Files.
  •  Name the file template.htm.
  •  Click Save.

You have basic HTML document now, to see some result put the following code in title and body tags. 
<html>
<head>
<title>This is document title</title> 
</head> 
<body> <h1>This is a heading</h1> <p>Document description goes here.....</p> </body> 
</html>
Now you have created one HTML page and you can use a Web Browser to open this HTML file to see the result. Hope you understood that Web Pages are nothing but they are simple HTML files with some content which can be rendered using Web Browsers. 

HTML Document Structure:
An HTML document starts and ends with <html> and >/html> tags. These tags tell the browser that the entire document is composed in HTML. Inside these two tags, the document is split into two sections:
 The <head>...</head> elements, which contain information about the document such as title of the document, author of the document etc. Information inside this tag does not display outside.
 The <body>...</body> elements, which contain the real content of the document that you see on your screen.

HTML Tags and Elements:
HTML language is a markup language and we use many tags to markup text. In the above example you have seen <html>, <body> etc. are called HTML tags or HTML elements. Every tag consists of a tag name, sometimes followed by an optional list of tag attributes , all placed between opening and closing brackets (< and >). The simplest tag is nothing more than a name  appropriately enclosed in brackets, such as <head> and <i>. More complicated tags contain one or more attributes , which specify or modify the behaviour of the tag. According to the HTML standard, tag and attribute names are not case-sensitive. There's no difference in effect between <head>, <Head>, <HEAD>, or even <HeaD>; they are all equivalent. But with XHTML, case is important: all current standard tag and attribute names are in lowercase.

HTML is Forgiving?
A very good quality associated with all the browsers is that they would not give any error if you have not put any HTML tag or attribute properly. They will just ignore that tag or attribute and will apply only correct tags and attributes before displaying the result. We can not say, HTML is forgiving because this is just a markup language and required to format documents.

HTML Basic Tags
The basic structure for all HTML documents is simple and should include the following minimum elements or tags:
 <html> - The main container for HTML pages
 <head> - The container for page header information
 <title> - The title of the page
 <body> - The main body of the page
Remember that before an opening <html> tag, an XHTML document can contain the optional XML declaration, and it should always contain a DOCTYPE declaration indicating which version of XHTML it uses. Now we will explain each of these tags one by one. In this tutorial you will find the terms element and tag are used interchangeably.

The <html> Element:
The <html> element is the containing element for the whole HTML document. Each HTML document should have one <html> and each document should end with a closing </html> tag.
Following two elements appear as direct children of an <html> element:
 <head>
 <body>
As such, start and end HTML tags enclose all the other HTML tags you use to describe the Web page.

The <head> Element:
The <head> element is just a container for all other header elements. It should be the first thing to appear after the opening <html> tag.
Each <head> element should contain a <title> element indicating the title of the document, although it may also contain any combination of the following elements, in any order:

  •  The <base> tag is used to areate a "base" url for all links on the page. Check HTML Base tag.
  •  The <object> tag is designed to include images, JavaScript objects, Flash animations, MP3 files, QuickTime movies and other components of a page. Check HTML Object tag.
  •  The <link> tag is used to link to an external file, such as a style sheet or JavaScript file. Check HTML Link tag.
  •  The <style> tag is used to include CSS rules inside the document. Check HTML Style tag.
  •  The <script> tag is used to include JAVAScript or VBScript inside the document. Check HTML Script tag.
  •  The <meta> tag includes information about the document such as keywords and a description, which are particularly helpful for search applications. Check HTML Meta tag.

Example:
Following is the example of head tag.
 <head>
 <title>HTML Basic tags</title> <meta name="Keywords" content="HTML, Web Pages" /> <meta name="description" content="HTML Basic Tags" /> <base href="http://www.tutorialspoint.com" /> <link rel="stylesheet" type="text/css" href="tp.css" /> <script type="text/javascript"> _uacct = "UA-232293"; urchinTracker(); </script>
 </head>

The <title> Element:
You should specify a title for every page that you write inside the <title> element. This element is a child of the <head> element). It is used in several ways:
 It displays at the very top of a browser window.
 It is used as the default name for a bookmark in browsers such as IE and Netscape.  Its is used by search engines that use its content to help index pages. Therefore it is important to use a title that really describes the content of your site. The <title> element should contain only the text for the title and it may not contain any other elements. Here is the example of using title tag.
<head>
<title>HTML Basic tags</title>
</head>

The <body> Element:
The <body> element appears after the <head> element and contains the part of the Web page that you actually see in the main browser window, which is sometimes referred to as body content. A <body> element may contain anything from a couple of paragraphs under a heading to more complicated layouts containing forms and tables. Most of what you will be learning in this and the following five chapters will be written between the opening <body> tag and closing </body> tag. Here is the example of using body tag.
<body> <p>This is a paragraph tag.</p> </body>

Putting all together:
Now if we will put all these tags together, it will constitute a complete HTML document as follows:
<html>
<head>
<title>HTML Basic tags</title> <meta name="Keywords" content="HTML, Web Pages" /> <meta name="description" content="HTML Basic Tags" /> <base href="http://www.tutorialspoint.com" /> <link rel="stylesheet" type="text/css" href="tp.css" /> <script type="text/javascript"> _uacct = "UA-232293"; urchinTracker(); </script> </head> <body> <p>This is a paragraph tag.</p>
</body>
</html>

Visual Basic Statements and Expressions


Visual Basic Statements and Expressions
·  The simplest statement is the assignment statement. It consists of a variable name, followed by the assignment operator (=), followed by some
sort of expression.
Examples:
StartTime = Now
Explorer.Caption = "Captain Spaulding"
BitCount = ByteCount * 8
Energy = Mass * LIGHTSPEED ^ 2
NetWorth = Assets - Liabilities
The assignment statement stores information.
· Statements normally take up a single line with no termi nator. Statements can be stacked by using a colon (:) to separate them. Example:
StartTime = Now : EndTime = StartTime + 10
(Be careful stacking statements, especially with If/End If structures. You may not get the response you desire.)
· If a statement is very long, it may be continued to the next line using the
continuation character, an underscore (_). Example:
Months = Log(Final * IntRate / Deposit + 1) _
/ Log(1 + IntRate)
·  Comment statements begin with the keyword Rem or a single quote ('). For
example:
Rem This is a remark
' This is also a remark
x = 2 * y ' another way to write a remark or comment
You, as a programmer, should decide how much to comment your code.
Consider such factors as reuse, your audience, and the legacy of your code.

How to create PDF file from Visual Basic


How to create PDF file from Visual Basic
: example "Hello, PDF!"
This page contatins step-by-step tutorial aimed to teach you how to createPDFfile from Visual Basic application using PDF Creator Pilot library.
1)InstallPDF Creator Pilotlibrary on your computer and runVisual Basic.
You will see New Project Wizard:
2)SelectStandard EXEproject type and clickOpento create new project.
Visual Basic will generate new projectProject1and will automatically open the main form of the generated project:
3)Now we should place a button that will launchl PDF generation function. To place the button just clickCommandButtonon the controls toolbar on the left:
Now press your right mouse button and then drag the mouse so you will set the rectangle for a new control and release the mouse button to create the control. It will look like this:
4)Visual Basic will create new button control on theForm1. Double-click on the control to letVisual Basiccreate the click handler function in the project code: Visual Basicwill create new function which will be launched every time when user clicks the button:
5)Now you have to write the code that will generate PDF file using PDF Creator Pilot . 
To generate PDF document you have to do the following:
1.connect to the PDF Creator Pilot library;
2.set the filename for PDF document;
3.draw "Hello, PDF!" message on the PDF page;
4.disconnect from the library.
Here is the source code:
Private Sub Command1_Click()
’ connect to library
SetPDF = CreateObject("PDFCreatorPilot.piPDFDocument")
’ initialize PDF Engine
PDF.StartEngine "demo@demo", "demo"
’ set PDF ouput filename
PDF.FileName = "HelloPDF_VB.pdf"
PDF.AutoLaunch = True’ auto-open generated pdf document
’ start document generation
PDF.BeginDoc
’ draw "HELLO, PDF" message on the current PDF page
PDF.PDFPAGE_BeginText
PDF.PDFPAGE_SetActiveFont "Verdana", True, False, False, False, 14, 0
PDF.PDFPAGE_TextOut 10, 20, 0, "HELLO, PDF!"
PDF.PDFPAGE_EndText
’ finalize document generation
PDF.EndDoc
’ disconnect from library
SetPDF = Nothing
End Sub
This function will generate PDF document and save it as "HelloPDF_VB.PDF"file in the application’s folder.
Hint:
You can simply copy the source code from the snippet above and then paste it in theVisual Basiccode editor as it’s shown on the
screenshot below:
6)PressF5to run the application (you can also use "Run" | "Start" menu command).
Visual Basic will run the application and you will see its main form:
7)Click "Command1" button and application will generate"HelloPDF_VB.PDF"file.
If you have any PDF viewer (for example,Adobe Acrobat Reader) installed on your computer then the library will launch it to open
the generated PDF document:
You can find the source code of this example in the"\Examples\VB\"sub-folder.

01 July, 2013

Organise your first project In Visual Basic


Organising your first project
The first step is to create a project template within VB, to organise and store your work. This will consist of a menu structure with headings that will let you access the many exercises and examples you complete.
Activity 1
·  Open VisualBasic 6.0
·  Use the file menu to open a new project with a blank form.
·  Use the properties window to set
– Main.frm as the form name.
– My programs as the caption.
– BackColor to White.
– BorderStyle to Fixed Single.
– WindowState to Maximised.
·  Find the Menu icon and click on it to select it. Enter the following menu headings:
Quit
Introduction with indented subheadings of Example1 , Example2
Click OK after each menu caption and name are typed.
·  Click on Quit menu heading and enter the following code. This procedure is used to exit from running the project display and return to the design screens.
Private Sub Quit_Click()
Unload me
End
End Sub
·  Use the <F5> function key to run the application to verify that the Menu structure is correct and that the Quit procedure is free from error.
·  Use the File menu to save your work as Main.frm and (your intitials)Project1.vbp
·  Use the file menu to open a new blank form (or the properties window)
·  Set the following form properties:
form name as Welcome caption to Example1 BackColor to White BorderStyle to Fixed Single

WindowState to Maximised
·  Click on the Example 1 main menu heading and enter the following code:
Private Sub Example1_Click()
Welcome.Show
End Sub
·  Save your work and run <F5> to ensure that it is free of errors.
·  Add two labels, an image and a command button to create a welcome screen. To do this Select label icon from the toolbox. Click towards the centre-top of your form and position and resize your label as required. With the label selected, use the properties window to Change the caption to WELCOME TO VISUAL BASIC

Choose a bright back colour
Set the font (Arial, underline, alignment centred, size 24 point, forecolour blue) 
Repeat to add the Enjoy label.
Use the image icon on your toolbox to add the image to your form. Use the
properties window of the image to select a picture. Use the command Button icon to add the button. Change its caption to RETURN. Then double-click the button and add the following line of code after the Command1_Click() procedure.
– Unload Welcome
·  Use the file menu to save your work and use <F5> to run the application.
·  DON’T FORGET TO SAVE (AND BACK UP TO FLOPPY) ALL YOUR WORK.
Event handlers and scroll bars Some definitions to learn
·  An object is a thing  anything that appears on the screen. An object has a set of properties. Each property of the object has a value.
e.g. Label.Caption = “Welcome to Visual Basic” where
Label is an object

Caption is a property of label
“Welcome to Visual Basic” is a value of the Caption property.
·  Events are things that happen on the screen. Event handlers transfer data to procedures that complete the task. The results of these procedures are returned back to other screen objects, e.g. onChange onClick 
·  A procedure is a group of statements designed to perform a specific task. A
procedure attached to an object, such as a button, is a command used to make something happen, e.g.
Public Sub Command2_Click()
Text1.Text = “This is a procedure.”
End Sub

Add new form to menu
As each new example and exercise solution is to be added to your project you will need to:
·  add a new form
·  set the form properties using the properties window
·  click on the main menu icon with the main form displayed to show the menu
designer
·  add a new menu heading
·  click on the menu heading to show the procedure code
·  to the procedure code, add the statement
FormXX.Show
where FormXX is the new form name.
Activity 2
1. Open a new form and change its name to ColourChanger. Place the following objects on this form.
 A heading label2 (Caption = Colour Changer)
 3 horizontal scroll bars (Set the max value property of all three to 255)
 3 other labels (2red, 3Green, 4Blue)  a command button to quit the form (Caption = Return)  another small label5 under the button with its visible property set to false.
2. Double click each scroll bar and add the following code to its _onChange() event. Use cut and paste to make the task easier.
Label1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
Label5.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
Label1.ForeColor = RGB(255 - HScroll1.Value, 255 - HScroll2.Value, 255 -
HScroll3.Value)
Label5.ForeColor = RGB(255 - HScroll1.Value, 255 - HScroll2.Value, 255 -
HScroll3.Value)
Label5.Visible = True
Label5.Caption = “WOW!”
Label2.BackColor = RGB(HScroll1.Value, 0, 0)
Label3.BackColor = RGB(0, HScroll2.Value, 0)
Label4.BackColor = RGB)0, 0, HScroll3.Value)
3. Double click the return button and add the following code to its _onClick() event
Unload Me
4. Use the Project Explorer window to return to your main form and double click
example 2 in your menu to add the appropriate code.
5. Use <F5> function key to test your project. Save and backup.

 
Twitter Bird Gadget