vb61

Share this page :

What is DOM?

The Document Object Model (DOM) is a programming interface for HTML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

With DOM, we can easily access and manipulate tags, IDs, classes, Attributes or Elements using commands or methods provided by Document object.

Methods of Document Object:

1.write(“string”): writes the given string on the document.

2.getElementById(): returns the element having the given id value.

Example 1:

<html>

<body>

<h1 id=”id1″>My Heading 1</h1>

<button type=”button” onclick=“document.getElementById(‘id1’).style.color = ‘red’ “>

Click Me!

</button>

</body>

</html>

Example 2:

<html>
<body>
<h2 align=center>Example of DOM</h2>

<p id=”xy”>

Click on the button below in order to change the text here.

</p>

<button onclick=”bt()”> Click here </button>

<script>

function bt()
{
var a=prompt(“Enter your name”)

document.getElementById(“xy”).innerHTML = a;
}

</script>

</body>
</html>

 

 

Visual Basic 6.0

 

Visual Basic is a high level programming language which evolved from the earlier DOS version called BASIC. BASIC means “Beginners All-purpose Symbolic Instruction Code”. Visual Basic is a visual programming language because programming is done in graphical environment.

In Visual Basic you just drag and drop any graphical object anywhere on the form and click on the object to enter the code window and start programming.

 

 

 

 

 

Visual Basic Extensions

 

Form                         –          .frm

Project                     –          .vbp

Application file    –          .exe

How to open Visual Studio?

Start  >  all programs  >  Microsoft Visual Studio 6.0  >  Microsoft Visual Basic 6.0  >  Standard EXE  >  open

 

What is Val function?

Val function converts the text data into a numeric value.

What is Dim statement?

The dim statement is used to declare variables in visual basic. Dim stands for dimension.

Private Sub Command1_Click()

Label4.Caption = (Val(Text1.Text) + Val(Text2.Text))

End Sub

Private Sub Command2_Click()

Label4.Caption = (Val(Text1.Text) – Val(Text2.Text))

End Sub

Private Sub Command3_Click()

Label4.Caption = (Val(Text1.Text) * Val(Text2.Text))

End Sub

Private Sub Command4_Click()

Label4.Caption = (Val(Text1.Text) / Val(Text2.Text))

End Sub

Private Sub Command5_Click()

Label4.Caption = (Val(Text1.Text) Mod Val(Text2.Text))

End Sub

Private Sub Command6_Click()

Label4.Caption = ” ”

Text1.Text = ” ”

Text2.Text = ” ”

End Sub

 

Calculate Odd & Even Number

 

 

Tools

Property

Change Property

Label1

Caption

Odd-Even Calculation
Label2

Enter a number
Label3

Result
Command1

Calculate
Command2

Reset
Text1, Text2

Text

 

Private Sub Command1_Click()

Dim x As Integer

x = Text1.Text

If x Mod 2 = 0 Then

Text2.Text = “Even number”

Else

Text2.Text = “Odd number”

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ” ”

Text2.Text = ” ”

End Sub

 

Check Maximum Number

 

 

Private Sub Command1_Click()

Dim x, y, z As Integer

x = Val(Text1.Text)

y = Val(Text2.Text)

z = Val(Text3.Text)

If ((x > y) And (x > z)) Then

MsgBox (“X is Maximum”)

ElseIf ((y > x) And (y > z)) Then

MsgBox (“y is maximum”)

Else

MsgBox (“z is maximum”)

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ” ”

Text2.Text = ” ”

Text3.Text = ” ”

End Sub

 

Write a VB program to create a mark sheet

 

 

Private Sub Command1_Click()

Dim a, b, c, d, sum, p As Double

a = Val(Text1.Text)

b = Val(Text2.Text)

c = Val(Text3.Text)

d = Val(Text4.Text)

sum = a + b + c + d

p = sum / 4

If (p >= 80) Then

Label6.Caption = “Total = ” & sum

Label7.Caption = “Percentage = ” & p

Label8.Caption = “Grade = A”

ElseIf (p >= 70) Then

Label6.Caption = “Total = ” & sum

Label7.Caption = “Percentage = ” & p

Label8.Caption = “Grade = B”

Else

Label6.Caption = “Total = ” & sum

Label7.Caption = “Percentage = ” & p

Label8.Caption = “Grade = C”

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ” ”

Text2.Text = ” ”

Text3.Text = ” ”

Text4.Text = ” ”

Label6.Caption = ” ”

Label7.Caption = ” ”

Label8.Caption = ” ”

End Sub

 

What is timer?

A timer control is invisible at run time & and its purpose is to send a periodic pulse to the current application.

What is checkbox?

Checkbox is used to deal with toggle options, which have only two possible states – true/ false, or yes/no.

What is common dialog control?

The common dialog control provides a standard set of dialog boxes for operations such as opening and saving files, setting print options, and selecting colors and fonts.

What is listbox?

The listbox represents a Windows control to display a list of items to a user. A user can select an item from the list.

What is combobox (drop-down)?

The ComboBox control is used to display a drop-down list of various items.

What is inputbox?

InputBox is used to prompt the user to enter the values.

Private Sub Check1_Click()

If Check1.Value = 1 Then

Check2.Value = 0

Shape1.BorderWidth = 5

Else

Shape1.BorderWidth = 1

End If

End Sub

Private Sub Check2_Click()

If Check2.Value = 1 Then

Check1.Value = 0

Shape1.BorderWidth = 10

Else

Shape1.BorderWidth = 1

End If

End Sub

Private Sub Command1_Click()

CommonDialog1.ShowColor

Shape1.BackColor = CommonDialog1.Color

End Sub

Private Sub Command2_Click()

CommonDialog1.ShowColor

Shape1.BorderColor = CommonDialog1.Color

End Sub

Private Sub Option1_Click()

If Option1.Value = True Then

Shape1.Shape = 0

End If

End Sub

Private Sub Option2_Click()

If Option2.Value = True Then

Shape1.Shape = 1

End If

End Sub

Private Sub Option3_Click()

If Option3.Value = True Then

Shape1.Shape = 2

End If

End Sub

Private Sub Option4_Click()

If Option4.Value = True Then

Shape1.Shape = 3

End If

End Sub

Private Sub Option5_Click()

If Option5.Value = True Then

Shape1.Shape = 4

End If

End Sub

Private Sub Option6_Click()

If Option6.Value = True Then

Shape1.Shape = 5

End If

End Sub

Write a VB program to print values in the listbox using loops

 

Private Sub Command1_Click()

Dim a, x As Integer

a = Val(Text1.Text)

For x = 1 To a

List1.AddItem x

Next

End Sub

Private Sub Command2_Click()

Text1.Text = ” ”

List1.Clear

Text1.SetFocus

End Sub

 

 

Private Sub Command1_Click()

List1.AddItem List2.Text

List2.RemoveItem List2.ListIndex

End Sub

 

Private Sub Command2_Click()

List2.AddItem List1.Text

List1.RemoveItem List1.ListIndex

End Sub

 

Private Sub Form_Load()

With List1

.AddItem “apple”

.AddItem “baby”

.AddItem “elephant”

.AddItem “heaven”

.AddItem “winter”

End With

End Sub

 

Private Sub List1_DblClick()

List1.RemoveItem (List1.ListIndex)

End Sub

 

Private Sub List2_DblClick()

List2.RemoveItem (List2.ListIndex)

End Sub

 

Write a VB program to change font face, size & color using common dialog & combo boxes

 

 

Private Sub Combo1_Click()

Text1.Font = Combo1.Text

End Sub

Private Sub Combo2_Click()

Text1.FontSize = Combo2.Text

End Sub

Private Sub Command1_Click()

CommonDialog1.ShowColor

Text1.ForeColor = CommonDialog1.Color

End Sub

Private Sub Form_Load()

With Combo1

.AddItem “Forte”

.AddItem “Wingdings”

.AddItem “Lucida Handwriting”

.AddItem “Arial”

.AddItem “Monotype Corsiva”

.AddItem “Impact”

End With

With Combo2

.AddItem “10”

.AddItem “15”

.AddItem “20”

.AddItem “25”

.AddItem “30”

.AddItem “35”

End With

End Sub

 

 

Write a VB program to create a stopwatch

 

 

Private Sub Command1_Click()

Timer1.Enabled = True

End Sub

 

Private Sub Command2_Click()

Timer1.Enabled = False

End Sub

 

Private Sub Command3_Click()

Timer1.Enabled = False

Label1.Caption = “0”

Label2.Caption = “0”

Label3.Caption = “0”

End Sub

 

 

Private Sub Timer1_Timer()

Label3.Caption = Label3.Caption + 1

If Label3.Caption = “60” Then

Label3.Caption = “0”

Label2.Caption = Label2.Caption + 1

End If

If Label2.Caption = “60” Then

Label2.Caption = “0”

Label1.Caption = Label1.Caption + 1

End If

End Sub

 

 

 

Share this page :