VB Lab
VB Lab
VB Lab
SIMPLE CALCULATOR
FORM DESIGN:
CODING:
Dim no1, choice As Integer
Private Sub Command1_Click()
Text1.Text = Text1.Text & 1
End Sub
Private Sub Command10_Click()
Text1.Text = Text1.Text & 0
End Sub
Private Sub Command11_Click()
Text1.Text = ""
End Sub
Private Sub Command12_Click()
If choice = 1 Then
Text1.Text = no1 + Text1.Text
ElseIf choice = 2 Then
Text1.Text = no1 - Text1.Text
ElseIf choice = 3 Then
Text1.Text = no1 * Text1.Text
ElseIf choice = 4 Then
Text1.Text = no1 / Text1.Text
ElseIf choice = 5 Then
End If
End Sub
Private Sub Command13_Click()
choice = 1
no1 = Val(Text1.Text)
Text1.Text = ""
End Sub
Private Sub Command14_Click()
choice = 2
no1 = Val(Text1.Text)
Text1.Text = ""
End Sub
Private Sub Command15_Click()
choice = 4
no1 = Val(Text1.Text)
Text1.Text = ""
End Sub
Private Sub Command16_Click()
choice = 3
no1 = Val(Text1.Text)
Text1.Text = ""
End Sub
Private Sub Command2_Click()
Text1.Text = Text1.Text & 2
End Sub
Private Sub Command3_Click()
Text1.Text = Text1.Text & 3
End Sub
Private Sub Command4_Click()
Text1.Text = Text1.Text & 4
End Sub
Private Sub Command5_Click()
Text1.Text = Text1.Text & 5
End Sub
Private Sub Command6_Click()
Text1.Text = Text1.Text & 6
End Sub
Private Sub Command7_Click()
Text1.Text = Text1.Text & 7
End Sub
Private Sub Command8_Click()
Text1.Text = Text1.Text & 8
End Sub
Private Sub Command9_Click()
Text1.Text = Text1.Text & 9
End Sub
OUTPUT:
2.LOOPS AND DECISION MAKING
A) FIBONACCI SERIES
Form Design:
CODING:
OUTPUT:
B) SUM OF N NUMBERS
FORM DESIGN:
CODING:
OUTPUT:
3.MENU AND MDI FORM
Form Design:
Coding:
Form1.Show
Form2.Show
Form3.Show
Me.Arrange vbCascade
End Sub
CommonDialog1.ShowColor
Form1.BackColor = CommonDialog1.Color
End Sub
Form1.Show
End Sub
Form2.Show
End Sub
Form3.Show
End Sub
Output:
4.RICHTEXT BOX
Form Design:
Coding:
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Dir1.Path = Drive1.Drive
End Sub
Image1.Picture = LoadPicture(RichTextBox1.Text)
End Sub
Output:
5.COMMONDIALOG CONTROL
Form Design:
Coding:
Dim i As Integer
CommonDialog1.Filter = "text(text)text"
CommonDialog1.ShowOpen
Do Until EOF(1)
i=i+1
Loop
Close #1
End Sub
Private Sub Command2_Click()
CommonDialog1.ShowSave
Close #1
End Sub
CommonDialog1.Flags = edicfboth
CommonDialog1.ShowFont
RichTextBox1.Font.Name = CommonDialog1.FontName
RichTextBox1.Font.Italic = CommonDialog1.FontItalic
End Sub
Output:
6.ANIMATION USING TIMERS
Form Design:
Coding:
A = A + 100
A = A + 100
A=0
End If
End Sub
Output:
7.NUMBER CONVERSION
Form Design:
Coding:
bp = " "
ss = Trim(Text1.Text)
Text1.SetFocus
Else
num = CInt(ss)
Text1.Enabled = False
num = num / 2
Loop
Label3.Caption = StrReverse(bp)
End If
End Sub
bp = " "
ss = Trim(Text1.Text)
Text1.SetFocus
Else
num = CInt(ss)
Text1.Enabled = False
num = num / 8
Loop
Label3.Caption = StrReverse(bp)
End If
End Sub
Private Sub Command3_Click()
Dim r As Integer
bp = " "
ss = Trim(Text1.Text)
Text1.SetFocus
Else
num = CInt(ss)
Text1.Enabled = True
Select Case r
Case 10
bp = bp & A
Case 11
bp = bp & B
Case 12
bp = bp & C
Case 13
bp = bp & D
Case 14
bp = bp & E
Case 15
bp = bp & F
Case Else
End Select
num = num / 16
Loop
Label3.Caption = StrReverse(bp)
End If
End Sub
Text1.Enabled = True
Text1.SetFocus
End Sub
End
End Sub
Output:
8.EMPLOYEE DETAILS
SQL> create table emp(ename varchar(20),eno number(6)primary key,desg
varchar(6),gender char(2),age number(5),doj date,salary number(12));
Table created.
ENAME VARCHAR2(20)
DESG VARCHAR2(6)
GENDER CHAR(2)
AGE NUMBER(5)
DOJ DATE
SALARY NUMBER(12)
1 row created.
SQL> /
1 row created
SQL> select*from emp;
SQL> commit;
Commit complete.
9.INVENTORY
SQL>create table inventory(productno number(5),productname
varchar(20),rate number(5));
Table created.
1 row created.
1 row created.
1 row created.
201 TV 15000
204 CD 250
205 AC 650
SQL> begin
3 commit;
4 end;
5 /
201 TV 18000
204 CD 300
205 AC 780
Table altered.
Table altered.
1 row updated.
1 row updated.
1 row updated.
SQL> update inventory set count=30,place='Madurai'where
productno=204;
1 row updated.
1 row updated.
Table created.
10.TRIGGERS
SQL> insert into inv_msc values(&itemno,'&itemname',&itemprice);
1 row created.
SQL> /
1 row created.
SQL> /
Table created.
3 declare
4 begin
7 end if;
8 end;
9 /
Trigger created.
1 row created.
SQL> insert into inv_trs
values(&itemno,'&it_pdate','&it_sdate','&custname');
1 row created.
ITEMNO NUMBER(10)
IT_PDATE DATE
IT_SDATE DATE
CUST_NAME VARCHAR2(30)
Table created.
SNAME VARCHAR2(20)
SMARK NUMBER(10)
SRESULT VARCHAR2(10)
1 row created.
1 row created.
1 row created.
1 mithran 25 f
2 arun 86 p
3 sam 78 p
mber(10),sresult varchar(10));
Table created.
Table created.
SQL> declare
2 v_no std1.sno%type;
3 v_name std1.sname%type;
4 v_mark std1.smark%type;
5 v_result std1.sresult%type;
6 cursor curs_std1 is
8 begin
9 open curs_std1;
11 loop
12 if v_result='p'then
14 else
15 insert into std1_fail values(v_no,v_name,v_mark,v_result);
16 end if;
19 end loop;
20 close curs_std1;
21 end;
22 /
1 mithran 25 f
2 arun 86 p
3 sam 78 p
12.STUDENT MARKLIST
Form Design:
Coding:
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Adodc1.Recordset.AddNew
Text1.SetFocus
End Sub
Private Sub Command2_Click()
End
End Sub
Adodc1.Recordset.Save
End Sub
Adodc1.Recordset.Update
End Sub
Adodc1.Recordset.Delete
End Sub
End Sub
Text8.Text = Text7.Text / 3
End Sub
SQL Coding:
SQL> create table stud(rollno number(10),name varchar(20),course
varchar(10),mark1 number(10),mark2 number(10),mark3 number(10),total
number(10),average number 10));
Table created.
ROLLNO NUMBER(10)
NAME VARCHAR2(20)
COURSE VARCHAR2(10)
MARK1 NUMBER(10)
MARK2 NUMBER(10)
MARK3 NUMBER(10)
TOTAL NUMBER(10)
AVERAGE NUMBER(10)
TOTAL AVERAGE
---------- ----------
Saji BCA 78 87 80
158 52
OUTPUT: