Programming Lab – VB & Oracle
1. Construction of an Arithmetic Calculator (Simple).
2. Writing simple programs using loops and decision-making statements.
 a. Generate Fibonacci series.
 b. Find the sum of N numbers.
3. Write a program to implement animation using timers.
4. Write a simple VB program to accept a number as input and convert it into
 a. Binary b. Octal c. Hexa-decimal
5. Write a program to create a menu and MDIForms.
6. Write a program to illustrate Common Dialog Control and to open, edit and save text file.
7. Write a program to display files in a directory using DriveListBox, DirListBox and
 FileListBox control and open, edit and save text file using Rich textbox control.
8. Create a table for Employee details with Employee Number as primary key and following
 fields: Name, Designation, Gender, Age, Date of Joining and Salary. Insert at least ten rows
 and perform various queries using any one Comparison, Logical, Set, Sorting and Grouping
 operators.
9. Write a PL/SQL to update the rate field by 20% more than the current rate in inventory
 table which has the following fields: Prono, ProName and Rate. After updating the table a
 new field (Alter) called for Number of item and place for values for the new field without
 using PL/SQL block.
10. 10.WriteaPL/SQL program to implement the concept of Triggers
11. Write a PL/SQL program to implement the concept “Procedures”.
12. Write a VB program to manipulate the student mark list with oracle database connectivity
 program.
 Common Dialog Control
Aim
 Write a program to illustrate Common Dialog Control and to open, edit and save text file.
Algorithm
1. Start the process.
2. Design a form with Rich Text Box for load and creating Text File.
3. Add the Common Dialog Control from Project  Components menu by selecting Microsoft
 Common Dialog Control.
4. Add the necessary coding to the both forms
5. Execute the project and test with text file.
6. Terminate the process.
Screen Design
Label RichTextBox Common Dialog Control Command Button
Coding
Private Sub Command1_Click()
 cmd1.Filter = "Text files{*.txt)|*.txt"
 cmd1.ShowOpen
 If cmd1.FileName <> "" Then
 Form1.Caption = cmd1.FileName
 intFreeFile = FreeFile
 Open cmd1.FileName For Input As #1
 strFileContent = Input(LOF(intFreeFile), 1)
 Form1.RichTextBox1.Text = strFileContent
 Close #1
 End If
End Sub
Private Sub Command2_Click()
 If Trim(RichTextBox1.Text) <> "" Then
 cmd1.Filter = "*.txt"
 cmd1.ShowSave
 If cmd1.FileName <> "" Then
 intFile = FreeFile
 Open cmd1.FileName For Output As #intFile
 Print #intFile, Form1.RichTextBox1.Text
 Close #intFile
 End If
 Form1.Caption = "Saved to " & cmd1.FileName
 Else
 MsgBox "No Content to Save.....", vbExclamation
 RichTextBox1.SetFocus
 End If
End Sub
Private Sub Command3_Click()
 If Trim(RichTextBox1.Text) = "" Then
 RichTextBox1.Text = ""
 RichTextBox1.SetFocus
 Else
 If MsgBox("Do want to save to file.....", vbYesNo) = vbYes
 Then
 cmd1.Filter = "*.txt"
 cmd1.ShowSave
 If cmd1.FileName <> "" Then
 intFile = FreeFile
 Open cmd1.FileName For Output As #intFile
 Print #intFile, Form1.RichTextBox1.Text
 Close #intFile
 End If
 Form1.Caption = "Saved to " & cmd1.FileName
 Else
 RichTextBox1.Text = ""
 RichTextBox1.SetFocus
 End If
 End If
End Sub
Private Sub Command4_Click()
 End
End Sub
Private Sub Form_Load()
 RichTextBox1 = ""
End Sub
 File Control Systems
Aim
 Write a VB program to display files in a directory using DriveListBox, DirListBox and
FileListBox control and open, edit and save text file using Rich text box control.
Algorithm
1. Start the process.
2. Design a form with Rich Text Box for load and creating Text File.
3. Design another form with DriveListBox, DirListBox and FileListBox for file process.
4. Add the necessary coding to the both forms
5. Execute the project and test with sample text file.
6. Terminate the process.
Screen Design
Form 1
* Form 1 Design is same as previous program (Common Dialog Control) –
Do not write line in your note
Form 2 Design
 Label
DriveListBox DirListBox FileListBox Text Box Command Box
Form1 Coding
Public value As Integer
Private Sub Command1_Click()
 value = 2
 Form2.Show
End Sub
Private Sub Command2_Click()
If Trim(RichTextBox1.Text) <> "" Then
 value = 3
 Form2.Show
Else
 MsgBox "No Content to Save.....", vbExclamation
 RichTextBox1.SetFocus
End If
End Sub
Private Sub Command3_Click()
If Trim(RichTextBox1.Text) = "" Then
 RichTextBox1.Text = ""
 RichTextBox1.SetFocus
Else
 If MsgBox("Do want to save to file.....", vbYesNo) = vbYes Then
 value = 1
 Form2.Caption = "Save as"
 Form2.Show
 Else
 RichTextBox1.Text = ""
 RichTextBox1.SetFocus
 End If
End If
End Sub
Private Sub Command4_Click()
 End
End Sub
Private Sub Form_Load()
 value = 1
 RichTextBox1 = ""
End Sub
Form2 Coding
Public mstrDrive As String
Dim intFile As Integer
Dim strFile As String
Private Sub Command1_Click()
If Trim(Text1) <> "" Then
 If Form1.value = 1 Or Form1.value = 3 Then ' Save
 strFile = Dir1.Path & "\" & Trim(Text1) & ".txt"
 intFile = FreeFile
 Open strFile For Output As #intFile
 Print #intFile, Form1.RichTextBox1.Text
 Close #intFile
 Unload Me
 MsgBox "File Saved & Closed....."
 Form1.RichTextBox1 = ""
 Form1.RichTextBox1.SetFocus
 ElseIf Form1.value = 2 Then ' Open
 strFile = Dir1.Path & "\" & Trim(Text1)
 intFreeFile = FreeFile
 Open strFile For Input As #1
 strFileContent = Input(LOF(intFreeFile), 1)
 Form1.RichTextBox1.Text = strFileContent
 Close #1
 Unload Me
 Form1.RichTextBox1.SetFocus
 Else
 MsgBox "Please Enter / Select a File name....", vbCritical
 Text1.SetFocus
 End If
End If
End Sub
Private Sub Command2_Click()
 Unload Me
 Form1.RichTextBox1.SetFocus
End Sub
Private Sub Dir1_Change()
 File1.Path = Dir1.Path
End Sub
Private Sub Dir1_Click()
 With Dir1
 .Path = .List(.ListIndex)
 End With
End Sub
Private Sub Drive1_Change()
 On Error Resume Next
 Dir1.Path = Drive1.Drive
 If Err.Number <> 0 Then
 MsgBox "Drive selected is unavailable.", vbInformation,
"Drive Unavailable"
 Drive1.Drive = mstrDrive
 Else
 mstrDrive = Drive1.Drive
 End If
End Sub
Private Sub File1_Click()
 Text1 = File1.FileName
 Text1.SetFocus
End Sub
Private Sub Form_Load()
 mstrDrive = "C:"
 If Form1.value = 1 Then
 Command1.Caption = "Save"
 ElseIf Form1.value = 2 Then
 Form2.Caption = "Open"
 Command1.Caption = "Open"
 End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
 If Form1.value = 1 Or Form1.value = 3 Then
 If Trim(Text1) = "" Then
 MsgBox "Enter a File name to save...."
 Text1.SetFocus
 Else
 Command1_Click
 End If
 ElseIf Form1.value = 2 Then
 If Trim(Text1) = "" Then
 MsgBox "Select a File name to open...."
 Text1.SetFocus
 Else
 Command1_Click
 End If
 Else
 Text1.SetFocus
 End If
End If
End Sub
 ########