Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Saturday, May 28, 2011

VB : Multimedia Player


A multimedia player that can play all kinds of media files such as wav, midi, mp3, mpeg video, avi video and so on. When you launch the program, you can select files of different types from different drives. After you have selected a particular files, you can play it using the customized button or you can use the buttons of the multimedia control

In this program, you need to insert the Microsoft Multimedia Control, a combo box, a dirListBox, a DriveListBox, a fileListbox, a picture box(to play the video) , a text box and four command buttons which you label as "Play", "Open","Stop" and "Exit".One of the most important procedures is to open various audio files, the codes are as follow:



























Refer the below given program.....then do this as your home work..(feel free to contact, if u fail to get the answer.....before contacting, make sure u tried your best..)
Copies files from one location to other

=========================================================================
Back to Home   &  VB

VB-15 : The four calculations



It is too nice to know the difference in coding between JAVA and VB.See the same program i did in JAVA. 

==============================================
B) Property :
Label       : NAME-Label1, CAPTION-Enter first number
Textbox   : NAME – text1   , Text-(should kept blank)
Label        : NAME-Label2, CAPTION-Enter second number
Textbox    : NAME – text2   , Text-(should kept blank)
OptionButton : NAME-Option1,CAPTION-Add
OptionButton : NAME-Option2,CAPTION-Subtract
OptionButton : NAME-Option3,CAPTION-Multiply
OptionButton : NAME-Option4,CAPTION-Devide
Command Button  :  NAME -  Command5, CAPTION-Exit


C) 
  Attaching Code to the Object :



Private Sub Command1_Click()
End
End Sub

Private Sub Option1_Click()
If Option1.Value Then
c = Val(Text1.Text) + Val(Text2.Text)
MsgBox c
End If
End Sub

Private Sub Option2_Click()
If Option2.Value Then
c = Val(Text1.Text) - Val(Text2.Text)
MsgBox c
End If
End Sub

Private Sub Option3_Click()
If Option3.Value Then
c = Val(Text1.Text) * Val(Text2.Text)
MsgBox c
End If
End Sub

Private Sub Option4_Click()
If Option4.Value Then
c = Val(Text1.Text) / Val(Text2.Text)
MsgBox c
End If
End Sub





Click   Simple Programs(3) to get an idea about Calculation.


 Refer Calculations using Grid control  & Simple Calculator also.



Back to Home   &  VB 
=========================================================================

VB-14 : Making decision with Select Case

Select Case structure is an alternative to IF..THEN......ElseIF...for selectively executing one block of statements from among multiple blocks of statements.
You can add any number of ElseIF clauses as you need to provide alternative choices.A better way to choose between several alternatives is the Select Case statement as in the example given below:


Let there be a text field in which the user is supposed to enter the choices from a range of options given.


Enter any fruit from one of the following choices : Mango,apple,banana,orange and pineapple.


A)   Property :
Comman Button : NAME – Command1,CAPTION-Submit
Text Box          :NAME-text1,TEXT-(Blank)




B)   Attaching Code to the Object :
Private Sub Command1_Click()
Select Case Text1.Text
Case "Mango"
MsgBox "Mango is in green colour"
Case "Banana"
MsgBox "Banana is in yellow colour"
Case "Orange"
MsgBox "Orange is in orange colour"
Case "Apple"
MsgBox "Apple is in red colour"
Case "Pineapple"
MsgBox "Pineapple is in cream colour"
Case Else
MsgBox "The fruit you choose is not in the list"
End Select
End Sub

 ========================================================================
Back to Home   &  VB

Friday, May 27, 2011

VB-13 : Set Focus(If-Then-Elseif-Endif)


Elseif clause is a variation of IF..THEN.....ELSE statement.By using this , we can control program flow.

Here, let be a field in the table as "age". Let the value in age cannot be less than 10 and greater than 60.So the code do check the value in the text box control named text1 is can be placed in the lost focus event of the text1 control.

A)   Property :
Textbox


B)   Attaching Code to the Object :
Private Sub Text1_LostFocus()
If Val(Text1.Text) < 10 Then
MsgBox "age cannot be less than 10"
Text1.SetFocus
ElseIf Val(Text1.Text) > 60 Then
MsgBox "age cannot be greater than 60"
Text1.SetFocus
Else
MsgBox "age entered correctly"
End If
End Sub

You can add any number of ElseIF clauses as you need to provide alternative choices.A better way to choose between several alternatives is the Select Case statement as in example VB-14 : Making decision with Select Case


               VB-11 : Set Focus(If-Then-Endif)
               VB-12 : Set Focus(If-Then-Else-Endif)




=========================================================================
Back to Home   &  VB

VB-12 : Set Focus(If-Then-Else-Endif)

Sometimes you have to run certain statements IF A condition is true and run others IF A condition is false.
Then you can use an IF...THEN.....ELSE statement to define two blocks of executable ststements:
One block to run if the condition is TRUE,
and the other block to run if the condition is FALSE.


A)   Property :

Textbox

B)   Attaching Code to the Object :


Private Sub Text1_LostFocus()
If Text1.Text = " " Then
MsgBox "Sorry!name cannot be left blank"
chance = chance + 1
Text1.SetFocus
Else
MsgBox "Great!name was successfully entered"
End If
End Sub



Refer : VB-10 : Set Focus(If-Then)



=========================================================================
Back to Home   &  VB

VB-11 : Set Focus(If-Then-Endif)

To run more than one line of code,you must use multiple line(or block)syntax.
This syntax includes the ENDIF statements;


A)   Property :
Text Box (Same as VB-10)


B)   Attaching Code to the Object :


Private Sub Text1_LostFocus()
If Text1.Text = " " Then
MsgBox "Sorry!name cannot be left blank"
chance = chance + 1
Text1.SetFocus
End Sub


Refer : VB-10 : Set Focus(If-Then)



=========================================================================
Back to Home   &  VB

VB-10 : Set Focus(If-Then)

This program does not allow the user to move out of the text box till the user enters some value in it.
This example omits the ELSE and the END IF keywords.


A)   Property :
Text Box : NAME-Text1, TEXT-(Should be kept blank)

B)   Attaching Code to the Object :


Private Sub Text1_LostFocus()
If Text1.Text = " " Then MsgBox "Sorry!name cannot be left blank"
Text1.SetFocus
End Sub

Note : To run more than one line of code,we must includes the ENDIF statements.Refer VB-11 : Set Focus(If-Then-Endif) in which we are using ENDIF
==========================================

Refer : VB-11 : Set Focus(If-Then-Endif)

=========================================================================
Back to Home   &  VB

VB-9 : Print name 10 times(For-Next Loop)


Refer Print "Hello" 10 times(Do-While) also.

We need 2 command buttons.
The output will print names of first 10 students in the array batch on the click event(For-NextLoop)

A)   Property :
Command button : NAME- Command1 , CAPTION- Click
Command button : NAME- Command2 , CAPTION- Exit




B)   Attaching Code to the Object :
Private Sub Command2_Click()
End
End Sub

Private Sub Form_Click()
Dim i As Integer
For i = 0 To 9
Print Batch(i)
Next i
End Sub




=========================================================================
(Check the output)


Back to Home   &  VB

VB-8 : Print "Hello" 10 times(Do-While)


Refer Print name 10 times(For-Next Loop) also.

We need 2 command buttons.
The output will print "Hello" 10 times(Do-While Loop)

A)   Property :
Command button : NAME- Command1 , CAPTION- Click
Command button : NAME- Command2 , CAPTION- Exit




B)   Attaching Code to the Object :
Private Sub Command1_Click()
Dim num, count
num = 10
count = 0
Do While count < num
Print "Hello"
count = count + 1
Loop
End Sub

Private Sub Command2_Click()
End
End Sub


=============================================
Back to Home   &  VB

Wednesday, May 25, 2011

VB-7 : Part of an OLE Object

Refer VB-6 : Creating OLE at Design time also.This code links or embeds the complete file.
In case, a part of the file is to be used as an object, the steps involved are as follows:



Here we need two command buttons ,and one OLE ( Once the OLE box has appeared,click CANCEL to remove this dialog box)

A)   Property :
Command button : NAME- Command1 , CAPTION- Use OLE
Command button : NAME- Command2 , CAPTION- Exit
OLE                     : NAME-OLE1



B)   Attaching Code to the Object :
Private Sub Command1_Click()
If OLE1.PasteOK = True Then
OLE1.PasteSpecialDlg
End If
If OLE1.OLEType = 3 Then
MsgBox "Nothing has been copied"
End If
End Sub

Private Sub Command2_Click()
End
End Sub

Back to Home   &  VB

VB-6 : Creating OLE at Design time


Using the “insert Object dialog box” we can insert image,media-clip,charts,word file etc..on design time itself.
We can browse files and can create new one.

Two command buttons ,and one OLE ( Once the OLE box has appeared,click CANCEL to remove this dialog box)

A)   Property :
Command button : NAME- Command1 , CAPTION- Use OLE
Command button : NAME- Command2 , CAPTION- Exit
OLE                     : NAME-OLE1

B)   Attaching Code to the Object :
Private Sub Command1_Click()
OLE1.InsertObjDlg
End Sub

Private Sub Command2_Click()
End
End Sub

This code links or embeds the complete file.(Refer VB-7 : Part of an OLE Object  also)
=========================================================================
Back to Home   &  VB