Академический Документы
Профессиональный Документы
Культура Документы
CALCULATOR
FORM DESIGN
CODING
Private Sub OFF_Click() End End Sub Private Sub plus_Click () Text1.Text = " " preval = curval curval = 0 choice = "+" End Sub Private Sub negative_Click() curval = -curval Text1.Text = curval End Sub Private Sub mul_Click() Text1.Text = " " preval = curval curval = 0 choice = "*" End Sub
Private Sub minus_Click() Text1.Text = " " preval = curval curval = 0 choice = "-" End Sub Private Sub equal_Click() Select Case choice Case "+" result = preval + curval Text1.Text = Str(result) Case "-" result = preval - curval Text1.Text = Str(result) Case "*" resulty = preval * curval Text1.Text = Str(result) Case "/" result = preval / curval Text1.Text = Str(result) End Select End Sub
Private Sub div_Click() Text1.Text = " " preval = curval curval = 0 choice = "/" End Sub
OUTPUT
FORM DESIGN
CODING
Private Sub colorfont_Click() cmd.ShowColor rtbx1.SelColor = (cmd.Color) End Sub Private Sub fontstyle_Click() cmd.ShowFont rtbx1.SelFontName = (cmd.FontBold) rtbx1.SelFontSize = (cmd.FontSize) rtbx1.SelItalic = (cmd.FontItalic) End Sub Private Sub openfile_Click() cmd.ShowOpen rtbx1.LoadFile (cmd.FileName) End Sub Private Sub savefile_Click() cmd.ShowSave rtbx1.savefile (cmd.FileName) End Sub
OUTPUT
CAR ANIMATION
FORM DESIGN
CODING
Dim iAs Integer Dim X As Integer Private Sub Command1_Click() Timer1.Enabled = True Timer2.Enabled = True End Sub
Private Sub Timer2_Timer() i=i+1 Select Case i Case 1 Shape1.FillStyle = 2 Shape2.FillStyle = 2 Case 2 Shape1.FillStyle = 4 Shape2.FillStyle = 4 Case 3 Shape1.FillStyle = 5 Shape2.FillStyle = 5 Case 4 Shape1.FillStyle = 5 Shape2.FillStyle = 5 i=0 End Select End Sub
OUTPUT
MSFLEX GRID
FORM DESIGN
CODING
Dim a As Integer Dim x As Integer Dim y As Integer Private Sub ADD_Click() For x = 1 To 12 MSFlexGrid1.Row = x For y = 1 To 12 MSFlexGrid1.Col = y MSFlexGrid1.Text = x + y Next y Next x End Sub Private Sub DIV_Click() For x = 1 To 12 MSFlexGrid1.Row = x For y = 1 To 12 MSFlexGrid1.Col = y MSFlexGrid1.Text = Round((x / y), 2) Next y Next x
End Sub Private Sub Form_Load() MSFlexGrid1.Col = 0 For x = 1 To 12 MSFlexGrid1.Row = x MSFlexGrid1.Text = Str(x) Next x MSFlexGrid1.Row = 0 For x = 1 To 12 MSFlexGrid1.Col = x MSFlexGrid1.Text = Str(x) Next x End Sub Private Sub MUL_Click() For x = 1 To 12 MSFlexGrid1.Row = x For y = 1 To 12 MSFlexGrid1.Col = y MSFlexGrid1.Text = x * y Next y Next x End Sub Private Sub SUB_Click()
OUTPUT
CODING
FORM 1
Private Sub cancel_Click() End End Sub Private Sub submit_Click() If Text1.Text = "admin" And Text2.Text = "pass" Then grp.Show Else MsgBox "wrong input" End If End Sub
FORM 2 Private Sub add_Click() Adodc1.Recordset.AddNew End Sub Private Sub calculate_Click() grp.Text = Val(da.Text) + Val(hra.Text) + Val(prf.Text) + Val(slry.Text) End Sub Private Sub delete_Click() Adodc1.Recordset.delete
Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MovePrevious End If End Sub Private Sub next_Click() Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveFirst End If End Sub Private Sub previous_Click() Adodc1.Recordset.MovePrevious If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveLast End If End Sub Private Sub REPORT_Click() DataReport1.Show End Sub Private Sub update_Click() Adodc1.Recordset.updat End sub
OUTPUT
STUDENT DETAILS
FORM 1
FORM 2
FORM 3
CODING
FORM 1
Private Sub MNPLTLN_Click() Form2.Show End Sub Private Sub RPT_Click() DataReport1.Show End Sub Private Sub STD_Click() Form3.Show End Sub
FORM 3
Private Sub ADD_Click() Adodc1.Recordset.AddNew End Sub Private Sub average_Click() Text7.Text = Val(text6.Text) / 3 End Sub Private Sub clear_Click() Text1.Text = ""
Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" End Sub Private Sub delete_Click() Adodc1.Recordset.delete Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MovePrevious End If End Sub Private Sub exit_Click() End End Sub Private Sub menu_Click() Form1.Show End Sub Private Sub next_Click() Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF = True Then
Adodc1.Recordset.MoveFirst End If End Sub Private Sub previous_Click() Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveFirst End If End Sub Private Sub total_Click() Text6.Text = Val(text3.Text) + Val(text4.Text) + Val(text5.Text) End Sub Private Sub update_Click() Adodc1.Recordset.update End Sub
OUTPUT
#include<afxwin.h> class MyFrame:public CFrameWnd { public: MyFrame() { Create (0,"My first application"); } }; class Myapp:public CWinApp { MyFrame * w; public: int InitInstance() { w=new MyFrame(); m_pMainWnd=w; m_pMainWnd->ShowWindow(1); return 1; } }; Myapp a;
OUTPUT
MESSAGE MAP
#include<afxwin.h> class MyFrame:public CFrameWnd { public: MyFrame() { Create(0,"Message demo"); } int OnCreate() { MessageBox("First Message","Hello"); return 0; } int OnPaint() { CFrameWnd::OnPaint(); MessageBox("Second Message","Hi"); return 0; } DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(MyFrame,CFrameWnd) ON_WM_CREATE() ON_WM_PAINT() END_MESSAGE_MAP() class MyApp:public CWinApp { int InitInstance() { MyFrame * p; p=new MyFrame(); m_pMainWnd = p; p->ShowWindow(1); return 1; } };MyApp b;
OUTPUT
SHAPE
#include<afxwin.h> class MyFrame:public CFrameWnd { public: MyFrame() { Create(0,"drawing rectangle, pie"); } void OnPaint() { CPaintDC d(this); CBrush MyBrush(RGB(255,0,0)); d.SelectObject(&MyBrush); d.MoveTo(10,10); d.Rectangle(10,20,200,100); d.Ellipse(140,150,230,240); } DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(MyFrame,CFrameWnd) ON_WM_PAINT() END_MESSAGE_MAP() class MyApp:public CWinApp { int InitInstance() { MyFrame * p; p=new MyFrame(); p->ShowWindow(1); m_pMainWnd=p; return 1; } }; MyApp c;
OUTPUT
RDBMS
SIMPLE QUERIES
CREATING TABLE
SQL> create table product_master 2 (product_no varchar(6), 3 description varchar(15), 4 profitpercent number(6), 5 unitmeasure varchar(5), 6 qty_on_hand number(4), 7 reorder number(3), 8 sell_price number(6), 9 cost_price number(6));
Table created.
QUERIES
SQL> select product_no,description from product_master where cost_price>=2000; PRODUC DESCRIPTION ------ --------------P03453 MONITORS P07868 KEYBOARDS P07885 CD DRIVE P07965 540 HDD
PRODUC DESCRIPTION ------ --------------- ------------P07868 KEYBOARDS P07885 CD DRIVE P07965 540 HDD
PROFITPERCENT
2 3 4
no rows selected
SQL> select product_no,description,profitpercent,sell_price from product_master where profitpercent not between 10 and 15;
PRODUC DESCRIPTION
PROFITPERCENT
SELL_PRICE
------ --------------- ------------- ---------p00001 1.44 FLOPPIES P03453 MONITORS P06734 MOUSE P07865 1.22 FLOPPIES P07868 KEYBOARDS P07885 CD DRIVE P07965 540 HDD P07975 1.44 DRIVE P08865 1.22 DRIVE 5 6 5 5 2 3 4 5 5 525 12000 1050 525 3150 250 8400 1050 1050
1.44 FLOPPIES 540 HDD CD DRIVE KEYBOARDS MONITORS MOUSE 9 rows selected.
PRODUC -----p00001 P08865 P07975 P07965 P07885 P07868 P07865 P06734 P03453 9 rows selected.
SQL> select product_no,description,qty_on_hand from product_master where qty_on_hand=200 2 Union 3 selectproduct_no,description,qty_on_hand from product_master where qty_on_hand=300; no rows selected SQL> select product_no,description,sell_price,cost_price from product_master where sell_price<1000 2 intersect 3 selectproduct_no,description,sell_price,cost_price from product_master where sell_price>1000;
no rows selected
BUILT IN FUNCTIONS
CREATING TABLE
SQL> create table product_master 2 (product_no varchar(6), 3 description varchar(15), 4 profitpercent number(6), 5 unitmeasure varchar(5), 6 qty_on_hand number(4), 7 reorder_ivi number(3), 8 sell_price number(6), 9 cost_price number(6)); Table created. SQL> insert into product_master values ('&product_no','&description',&profitpercent,'&unitmeasure',&qty_on_hand,&reo rder_ivi,&sell_price);
PROD_N DESCRIPTION PROFIT UNIT QTY_ON_HAND RECORDER SELL_PRICE COST_PRICE
------ ---------- -------------- ------ ----------- --------- ---------- -----------------------------------------------------------------P00001 FLOPPIES P03453 monitors P06734 mouse P07865 1floppie 5 6 5 5 2 PIECE PIECE PIECE PIECE PIECE 100 10 20 100 10 20 3 5 20 3 525 12000 1500 525 3150 500 11280 1250 500 3050
P07868 keyboard
FROM THE TABLE PRODUCT_MASTER SQL> select avg(sell_price) from product_master; AVG(SELL_PRICE) --------------4525
SQL> select min(qty_on_hand) from product_master; MIN(QTY_ON_HAND) ---------------10 SQL> select count(recorder) from product_master; COUNT(RECORDER) --------------5 SQL> select max(cost_price) from product_master; M\AX(COST_PRICE) --------------11280
ABS(-15) --------15 (ii)power(m,n) SQL> select power(2,3)from dual; POWER(2,3) ---------8 (iii)round(m,n) SQL> select round(15.19)from dual; ROUND(15.19) -----------15 (iv)sqrt(n) SQL> select sqrt(25)from dual;
SQRT(25) --------5
ELECTRICITY BILL
PL/SQL CODE
1 declare 2 cursoreb is select * from ebill; 3 begin 4 for e in eb 5 loop 6 if(e.unit>=500) then 7 e.amount:=((e.unit-500)*3)+600+100+50; 8 elsif (e.unit>=200) then 9 e.amount:=((e.unit-200)*2)+100+50; 10 elsif(e.unit>=100) then 11 e.amount:=((e.unit-100)*1)+50; 12 else 13 e.amount:=e.unit*0.5; 14 end if; 15 update ebill set amount = e.amount where cuso=e.cuso; 16 end loop; 17* end; PL/SQL procedure successfully completed
CREATION OF TABLE
SQL> create table ebill 2 (cuso varchar2(6), 3 custname varchar2(10), 4 unit number(4), 5 amount number(8,2));
Table created.
INSERTION
OUTPUT
CUSO CUSTNAME
UNIT AMOUNT
----- ---------- --------- --------------------------e001 e002 e003 anju amu ramu 200 500 453 150 750 550
SPLITTING OF TABLES
PL/SQL CODE
SQL> declare 2 cursor stud is select * from sent; 3 begin 4 for s in stud 5 loop 6 ifs.result='pass' then 7 insert into pas values(s.sid,s.name); 8 else 9 insert into fail values(s.sid,s.name); 10 end if; 11 end loop; 12 end; 13 /
CREATION OF TABLE
SQL> create table sent 2 (sid varchar2(4), 3 name varchar2(10), 4 result varchar2(6));
Table created.
Table created.
Table created.
INSERTION
SQL> insert into sent values 2 ('&sid','&name','&result'); Enter value for sid: e001 Enter value for name: gibin Enter value for result: pass old 2: ('&sid','&name','&result') new 2: ('e001','gibin','pass')
1 row created.
SQL> / Enter value for sid: e002 Enter value for name: arun Enter value for result: fail old 2: ('&sid','&name','&result') new 2: ('e002','arun','fail')
1 row created.
SQL> / Enter value for sid: e003 Enter value for name: renu Enter value for result: pass old 2: ('&sid','&name','&result') new 2: ('e003','renu','pass')
1 row created.
OUTPUT
JOINING OF TABLES
PL/SQL CODE
1 declare 2 cursorcur_id is select f.sid,f.sname,f.tot,s.addr from ftablef,stable s where f.sid=s.sid; 3 sid ftable.sid%type; 4 sname ftable.sname%type; 5 tot ftable.tot%type; 6 addr stable.addr%type; 7 nodata exception; 8 begin 9 open cur_id; 10 loop 11 fetch cur_id into sid,sname,tot,addr; 12 if(cur_id% notfound)then 13 raise nodata; 14 end if; 15 insert into ttable values(sid,sname,tot,addr); 16 end loop; 17 exception 18 when nodata then 19 if cur_id% rowcount=0 then
20 dbms_output.put_line('there is no more record'); 21 else 22 dbms_output.put_line('program executed'); 23 end if; 24* end; SQL> /
CREATION OF TABLES
Table created.
Table created.
INSERTION
SQL> insert into ftablevalues('&sid','&sname',&tot); SQL> insert into stable values('&sid','&addr');
OUTPUT
SID
SNAME
TOT
---------- -------------------- --------- S01 S02 S03 S04 aaa bbb ccc ddd 94 59 78 89
SID
SNAME
TOT
ADDR
---------- -------------------- --------- --------------S01 S02 S03 S04 SQL> aaa bbb ccc ddd 94 59 78 89 CBE BLR CLT TCR
TRIGGER
PL/SQL CODE
SQL> create or replace trigger validity 2 before insert on marks 3 for each row 4 begin 5 if :new.mark1>100 or :new.mark2>100 6 or :new.mark3>100 or :new.mark1<0 or 7 :new.mark2<0 or :new.mark3<0 then 8 raise_application_error(-20002,'invalid marks'); 9 end if; 10 end; 11 / Trigger created. Execution of code: SQL>z:\fibo.sql
CREATION OF TABLES
SQL> create table marks(mark1 number(3),mark2 number(3),mark3 number(3)); Table created
OUTPUT
SQL> insert into mark values(&mark1,&mark2,&mark3); Enter value for mark1: 192 Enter value for mark2: 79 Enter value for mark3: 49 old 1: insert into mark values(&mark1,&mark2,&mark3) new 1: insert into mark values(192,79,49) ERROR at line 1: ORA-20002:invalid marks ORA-06512:at"HR VALIDITY",line1 ORA-04088:error during execution of trigger'HR VALIDITY'
RECURSIVE FUNCTION
A.FACTORIAL
FUNCTION
SQL> create or replace function fact(n in number) 2 return number is num number; 3 begin 4 if n=0 then 5 return 0; 6 elsif n=1 then 7 return 1; 8 else 9 num:=n*fact(n-1); 10 end if; 11 returnnum; 12 end; 13 / Function created.
PL/SQL CODE
SQL> declare 2 numb number; 3 i number; 4 begin 5 numb:=&number; 6 dbms_output.put_line(fact(numb)); 7 end; 8 / Execution of code: SQL>z:\fact.sql
OUTPUT
B.FIBONOCCI
FUNCTION
SQL> create or replace function fact(n in number) 2 return number is num number; 3 begin 4 if n=0 then 5 return 0; 6 elsif n=1 then 7 return 1; 8 else 9 num:=n*fact(n-1); 10 end if; 11 return num; 12 end; 13 /
PL/SQL CODE
SQL> declare 2 no number; 3 i number; 4 begin 5 no:=&number; 6 for i in 0..(no-1) 7 loop 8 dbms_output.put_line(fibo(i)); 9 end loop; 10 end; 11 / Execution of code: SQL>z:\fibo.sql
OUTPUT
Enter value for number: 7 old 5: no:=&number; new 5: no:=7; 0 1 1 2 3 5 8 PL/SQL procedure successfully completed.