You are on page 1of 27

PROGRAM NO.

1
Aim: To check username and password.
Algorithm:
1.Start.
2.Design the form.
2.1Insert two text box.
2.2 Insert two labels.
2.3 Insert three command box.
3.Enter the code.
4.Run the program.
5.Stop
Code:
Private Sub Command1_Click()
If Text1.Text = "ANGITH" And Text2.Text = "HELLO" Then
MsgBox "SUCCESSFULLY LOGGED IN"
Else
MsgBox "INVALID USERNAME OR PASSWORD"
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub

Output:

PROGRAM NO.2
Aim:
To add and remove items from the list box.
Algorithm:
1.Start.
2.Design the form.
3.Enter the data.
4.Add the data.
5.Remove the data.
6.Display add and remove data.
7.Stop.
Code:
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "PLEASE ENTER SOME DATA"
Else
List1.AddItem Text1.Text
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
List1.RemoveItem List1.ListIndex
End Sub

Output:

PROGRAM NO.3
Aim:
To copy all items in a list box to combo box.
Algorithm:
1. Start.
2. Design the form.
3. Input data into text box.
4. Add data into list box.
5. Copy to combo box.
6. Add to list box.
7. Stop
Code:
Private Sub Command1_Click ()
If Text1.Text = "" Then
MsgBox "PLEASE ENTER SOME DATA"
Else
List1.AddItem Text1.Text
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click ()
List1.RemoveItem List1.ListIndex
End Sub
Private Sub Command3_Click ()
For I = 0 to List1.ListCount - 1
Combo1.AddItem List1.List (I)
Next I
MsgBox "COPIED ALL ITEMS"
End Sub
Private Sub Command4_Click ()
End
End Sub

Output:

PROGRAM NO.4
Aim:
To enter and display student information.
Algorithm:
1. Start.
2. Design the form.
3. Input data into text box.
4. Add data into list box.
5. Copy to combo box.
6. Add to list box.
7. Stop
Code:
Private Sub Command1_Click ()
Print Text1.Text, Text2.Text, Text3.Text, Text4.Text
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End Sub

Output:

PROGRAM NO.5
Aim:
To scroll left to right using Timer.
Algorithm:
1. Start.
2. Design the form.
3. Input data into text box.
4. Add data into list box.
5. Copy to combo box.
6. Add to list box.
7. Stop
Code:
Private Sub Form_Load()
Label1.Caption = "THIS IS THE EXAMPLE OF SCROLLING TEXT"
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim STR As String
STR = Label1.Caption
STR = Mid$(STR, 2, Len(STR)) + Left(STR, 1)
Form1.Label1.Caption = STR
End Sub

Output:

PROGRAM NO: 6
Aim:
To display system date and time on screen.
Algortithm:
1.Start
2.Design the form.
3.Run and click the command button.
4.Display system date and time.
5.Stop
Code:
Private Sub Command1_Click()
Print "today is"; Tab; Now
Print "day is"; Tab; DateValue(Now)
Print "time is"; Tab; TimeValue(Now)
End Sub

Output:

PROGRAM NO: 7
Aim:
To find day of a week of a given date.
Algortithm:
1.Start
2.Design the form
3.Input the date
4.Click the command button to show the day
5.Stop
Code:
Private Sub Command1_Click()
Dim a As Date
a = InputBox("Enter the date")
Print "Today is"; Format(a, "DDDD")
End Sub

Output:

PROGRAM NO: 8
Aim:
For a mini calculator function.
Algorithm:
1.Start
2.Design form.
3.Input the 1st and 2nd number.
4.Perform the operations.
5.Display the functions.
6.Stop
Code:
Dim num1 As Double
Dim num2 As Double
Dim op As String
Private Sub Command1_Click()
Text1.Text = Text1.Text & 0
End Sub
Private Sub Command2_Click()
Text1.Text = Text1.Text & 1
End Sub
Private Sub Command3_Click()
Text1.Text = Text1.Text & 2
End Sub
Private Sub Command4_Click()
Text1.Text = Text1.Text & 3
End Sub
Private Sub Command5_Click()
Text1.Text = Text1.Text & 4
End Sub
Private Sub Command6_Click()
Text1.Text = Text1.Text & 5
End Sub
Private Sub Command7_Click()
Text1.Text = Text1.Text & 6
End Sub
Private Sub Command8_Click()
Text1.Text = Text1.Text & 7
End Sub
Private Sub Command9_Click()
Text1.Text = Text1.Text & 8
End Sub

Private Sub Command10_Click()


Text1.Text = Text1.Text & 9
End Sub
Private Sub Command11_Click()
Text1.Text = Text1.Text & "."
End Sub
Private Sub Command12_Click()
Text1.Text = ""
End Sub
Private Sub Command13_Click()
num1 = Text1.Text
Text1.Text = ""
op = "+"
End Sub
Private Sub Command14_Click()
num1 = Text1.Text
Text1.Text = ""
op = "-"
End Sub
Private Sub Command15_Click()
num1 = Text1.Text
Text1.Text = ""
op = "*"
End Sub
Private Sub Command16_Click()
num1 = Text1.Text
Text1.Text = ""
op = "/"
End Sub
Private Sub Command17_Click()
num2 = Text1.Text
If op = "+" Then
Text1.Text = num1 + num2
ElseIf op = "-" Then
Text1.Text = num1 - num2
ElseIf op = "*" Then
Text1.Text = num1 * num2
ElseIf op = "/" Then
Text1.Text = num1 / num2
End If
End Sub

Output:

PROGRAM NO: 10
Aim:
To search all image files in your system.
Algorithm:
1.Start
2.Design form.
3.Search Picture.
4.Select it to the form.
5.Stop
Code:
Private Sub Command1_Click()
Dim a As String
a = "|*.bmp;*.jpg;*.gif"
CommonDialog1.Filter = a
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub

Output:

PROGRAM NO: 11
Aim:
For Notepad.
Algorithm:
1.Start
2.Design form.
3.Type the document
4.Edit the text using edit menu.
5.Format the text.
6.Save the file.
7.Open the file.
8.Exit from current page.
9.Stop
Code:
Private Sub new_Click()
Text1.Text = ""
End Sub
Private Sub open_Click()
Me.CommonDialog1.Filter = "textfile(*txt)|.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Do Until EOF(1)
Input #1, ContentFile
Text1 = Text1 & ContentFile & vbclrt
Loop
Close #1
End Sub
Private Sub save_Click()
Me.CommonDialog1.Filter = "textfile(*txt)|.txt"
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Output As #1
Print #1, Text1.Text
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub cut_Click()
Clipboard.SetText Me.Text1.SelText
Me.Text1.SelText = vbNullString
End Sub

Private Sub copy_Click()


Clipboard.SetText Me.Text1.SelText
End Sub
Private Sub paste_Click()
Me.Text1.SelText = Clipboard.GetText
End Sub
Private Sub bold_Click()
If Text1.FontBold = True Then
Text1.FontBold = False
Else
Text1.FontBold = True
End If
End Sub
Private Sub italic_Click()
If Text1.FontItalic = True Then
Text1.FontItalic = False
Else
Text1.FontItalic = True
End If
End Sub
Private Sub underline_Click()
If Text1.FontUnderline = True Then
Text1.FontUnderline = False
Else
Text1.FontUnderline = True
End If
End Sub
Private Sub f20_Click()
Text1.FontSize = 20
End Sub
Private Sub f30_Click()
Text1.FontSize = 30
End Sub
Private Sub f40_Click()
Text1.FontSize = 40
End Sub

Output:

PROGRAM NO: 12
Aim:
For a document using MDI Form.
Algorithm:
1.Start
2.Display the form.
3.Display the MDI Child Form
4.Stop
Code:
Private Sub child_Click()
Form1.Show
End Sub
Private Sub exitn_Click()
End
End Sub

Output:

PROGRAM NO: 13
Aim:
To search a record in MS Access database using data control.
Algorithm:
1.Start
2.Design the form.
3.Create the table,
4.Connect the database.
5.Enter the data in the textbox.
6.Search the data using data control.
7.Stop
Code:

PROGRAM NO: 14
Aim:
To delete record in MS Access database using data control.
Algorithm:
1.Start
2.Design the form.
3.Create the table,
4.Connect the database.
5.Enter the data in the textbox.
6.Delete the data using delete button.
7.Stop
Code:

PROGRAM NO: 15
Aim:
To perform the following operation in MS Access database using DAO:
(a)Move first record (b)Move next record (c)Move previous record (d)Move last record
Algorithm:
1.Start
2.Design the form.
3.Create the table,
4.Connect the database.
5.Enter the data in the textbox.
6.Add data in the table.
7.Move the first record using command button.
8. Move the previous record using command button.
9. Move the first record using command button.
10. Move the last record using command button.
11.Stop
Code:

You might also like