Вы находитесь на странице: 1из 29

Program-1

Dim n1 As Integer Dim BINARY, OCTAL As Single Dim HEX As String Private Sub Command1_Click() n1 = Val(Text1.Text) Text2.Text = "" Do While (n1 <> 0) BINARY = n1 Mod 2 n1 = n1 \ 2 Text2.Text = BINARY & Text2.Text Loop End Sub Private Sub Command2_Click() n1 = Val(Text1.Text) Text3.Text = "" Do While (n1 <> 0) octl = n2 Mod 8 n1 = n2 \ 8 Text3.Text = OCTAL & Text3.Text Loop End Sub Private Sub Command3_Click() N3= Val(Text1.Text) Text4.Text = "" Do While (n1 <> 0) HEX = n3 Mod 16 n1 = n3 \ 16 If (HEX >= 10) Then Select Case (HEX) Case 10: hexa = "a" Case 11: hexa = "b" Case 12: hexa = "c" Case 13: hexa = "d" Case 14: hexa = "e" Case 15: hexa = "f"

End Select End If Text4.Text = HEX & Text4.Text Loop End Sub Private Sub Command4_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text1.SetFocus End Sub Private Sub Command5_Click() End End sub

Program-2
Private Sub Command1_Click()

List1.AddItem (Text1.Text) End Sub Private Sub Command2_Click() Combo1.AddItem (List1.Text) End Sub Private Sub Command3_Click() Text1.Text = "" List1.Clear Combo1.Clear Text1.SetFocus End Sub Private Sub Command4_Click() End End Sub

Program-3
Public Public Public Public cval As Double pval As Double res As Double ch As String

Private Sub cmdac_Click(Index As Integer) Text1.Text = "" pval = cval End Sub Private Sub cmdadd_Click(Index As Integer) Text1.Text = "" pval = cval ch = "+" End Sub Private Sub cmddiv_Click(Index As Integer) Text1.Text = "" pval = cval cval = 0 ch = "/" End Sub Private Sub cmdequ_Click(Index As Integer) Select Case ch Case Is = "+" res = pval + cval Text1.Text = Str(res) Case Is = "-" res = pval - cval Text1.Text = Str(res) Case Is = "*" res = pval * cval Text1.Text = Str(res) Case Is = "/" res = pval / cval Text1.Text = Str(res) End Select cval = res End Sub Private Sub Cmdmin_Click(Index As Integer) Text1.Text = "" pval = cval cval = 0 ch = "-" End Sub Private Sub cmdmul_Click(Index As Integer)

Text1.Text = "" pval = cval ch = "*" End Sub Private Sub Command1_Click(Index As Integer) Text1.Text = Text1.Text & Command1(Index).Caption cval = Val(Text1.Text) End Sub Private Sub Command2_Click() End End Sub

Program-4
Private Sub mnufont_Click() CommonDialog1.Flags = cd / cfboth CommonDialog1.ShowFont RichTextBox1.setfontname = CommonDialog1.FontName RichTextBox1.setfontsize = CommonDialog1.FontSize RichTextBox1.setfontbold = CommonDialog1.FontBold RichTextBox1.setfontitalic = CommonDialog1.FontItalic End Sub

Private Sub mnunew_Click() RichTextBox1.Text = "" End Sub Private Sub mnuopen_Click() CommonDialog1.Filter = "textfiles(*.text)/*.text/alfiles(*.*)/*.*" CommonDialog1.ShowOpen RichTextBox1.LoadFile (CommonDialog1.FileName) End Sub Private Sub mnusave_Click() CommonDialog1.Filter = "textfiles(*.text)/*.text/alfiles(*.*)/*.*" CommonDialog1.ShowSave RichTextBox1.SaveFile (CommonDialog1.FileName) End Sub

Program-5
Dim Dim Dim Dim db As Database rs As Recordset score As Integer m1 As String

Private Sub Command1_Click() rs.MoveNext If Not rs.EOF Then Label1.Caption = rs(0) Label2.Caption = rs(1) Option1.Caption = rs(2) Option2.Caption = rs(3)

Option3.Caption = rs(4) Else Command1.Enabled = False MsgBox ("ur score is" & score) End If End Sub Private Sub Command2_Click() End End Sub Private Sub Form_Load() Set db = OpenDatabase("C:\Documents and Settings\Admin\My Documents\suji.mdb") Set rs = db.OpenRecordset("select * from neshu") score = 0 If Not rs.EOF Then rs.MoveFirst Label1.Caption = rs(0) Label2.Caption = rs(1) Option1.Caption = rs(2) Option2.Caption = rs(3) Option3.Caption = rs(4) End If End Sub Private Sub Option1_Click() If Option1.Value = True Then m1 = StrComp(Option1.Caption, rs.Fields(5)) If m1 = 0 Then score = Val(score) + 1 End If End If End Sub

Program-6
Private Sub mnuadd_Click() Dim newform As Form1 Set newform = New Form1 newform.Show End Sub Private Sub mnucascade_Click() Me.Arrange vbTileHorizontal End Sub Private Sub mnucolor_Click() CommonDialog1.ShowColor MDIForm1.ActiveForm.BackColor = CommonDialog1.Color End Sub

PROGRAM 7 Creation of table category_head SQL> create table category_head(category_code varchar2(20) primary key); Table created. Creation of table route_head SQL> create table route_head(route_id varchar2(20) primary key, category_code varchar2(20) references category_head(category_code)); Table created. Creation of table ticket_head SQL> create table ticket_head(ticket_no varchar2(20) primary key); Table created. Creation of table place_head SQL> create table place_head(place_id varchar2(20) primary key); Table created.

Creation of table ticket_detail SQL> create table ticket_detail(ticket_no varchar2(20) references ticket_head(ticket_no)); Table created. Creation of table route_detail SQL> create table route_detail(place_id varchar2(20) references place_head(place_id),route_id varchar2(20) references route_head(route_id)); Table created. Altering of table ticket_head SQL> alter table ticket_head add constraint chk check(ticket_no<500); Table altered. Altering of table ticket_head SQL> alter table route_head add distance long; Table altered.

PROGRAM 8 Inserting values into category_head SQL> insert into category_head values('mdr 2 chn'); 1 row created. SQL> insert into category_head values('mdr 2 cbe'); 1 row created. SQL> insert into category_head values('cbe 2 chn'); 1 row created. SQL> insert into category_head values('cbe 2 blr'); 1 row created. SQL> insert into category_head values('blr 2 chn'); 1 row created. Inserting values into route_head

SQL> insert into route_head values('mr 2 cn','mdr 2 chn', 450); 1 row created. SQL> insert into route_head values('mr 2 ce','mdr 2 cbe',360); 1 row created. SQL> insert into route_head values('ce 2 cn','cbe 2 chn',560); 1 row created. SQL> insert into route_head values('ce 2 br','cbe 2 blr',240); 1 row created. SQL> insert into route_head values('br 2 cn','blr 2 chn',520); 1 row created. Inserting values into ticket_head SQL> insert into ticket_head values(42); 1 row created. SQL> insert into ticket_head values(56); 1 row created. SQL> insert into ticket_head values(74); 1 row created. SQL> insert into ticket_head values(36); 1 row created. SQL> insert into ticket_head values(134); 1 row created. Inserting values into place_head SQL> insert into place_head values(100); 1 row created. SQL> insert into place_head values(123); 1 row created. SQL> insert into place_head values(146); 1 row created. SQL> insert into place_head values(172); 1 row created. SQL> insert into place_head values(183);

1 row created.

Inserting values into route_detail SQL> insert into route_detail values(100,'mr 2 cn'); 1 row created. SQL> insert into route_detail values(123,'mr 2 ce'); 1 row created. SQL> insert into route_detail values(146,'ce 2 cn'); 1 row created. SQL> insert into route_detail values(172,'ce 2 br'); 1 row created. SQL> insert into route_detail values(183,'br 2 cn'); 1 row created.

Inserting values into ticket_detail. SQL> insert into ticket_detail values(42); 1 row created. SQL> insert into ticket_detail values(56); 1 row created. SQL> insert into ticket_detail values(74); 1 row created. SQL> insert into ticket_detail values(36); 1 row created. SQL> insert into ticket_detail values(134); 1 row created. Altering table route_detail SQL> alter table route_detail add source varchar2(20); Table altered. SQL> alter table route_detail add destination varchar2(20); Table altered.

Updating table route_detail with source and destination SQL> update route_detail set source='madras', destination='cochin'where place_id=100; 1 row updated. SQL> update route_detail set source='madras',destination='coimbatore' where place_id=123; 1 row updated. SQL> update route_detail set source='coimbatore', destination='cochin' where place_id=146; 1 row updated. SQL> update route_detail set source='coimbatore', destination='bangalore' where place_id=172; 1 row updated. SQL> update route_detail set source='bangalore', destination='cochin' where place_id=183; 1 row updated. updating route_head with distance 500 SQL> update route_head set distance=500 where route_id='mr 2 ce'; 1 row updated. PROGRAM 9 9a.Select rows from ticketdetail such that ticket number greater than ticket number in ticket head Creating table tickethead SQL> create table thead(tno number(5),destination varchar2(20)); Table created. Inserting values into table tickethead SQL> insert into thead values(100,'Salem'); 1 row created. SQL> insert into thead values(101,'Bombay'); 1 row created. SQL> insert into thead values(102,'Coimbatore'); 1 row created. Creating table ticketdetail SQL> create table ticdetail(tno number(5),amount number(12,2),destination varchar2(20),datesval date); Table created.

Inserting values into table ticdetail SQL> insert into ticdetail values(102,30,'Erode','10-jan-2009'); 1 row created. SQL> insert into ticdetail values(110,40,'Avinashi','2-mar-2009'); 1 row created. SQL> insert into ticdetail values(115,50,'Ooty','19-mar-2009'); 1 row created. 9b. Select rows from rhead such that rid greater than rid of routedetail & pid should be 100 Creating table rhead SQL> create table rhead(rid number(5),pid number(5)) Table created. Inserting values into rhead SQL> insert into rhead values(1001,111); 1 row created. SQL> insert into rhead values(1002,112); 1 row created. SQL> insert into rhead values(1003,113); 1 row created. SQL> insert into rhead values(1004,114); 1 row created. SQL> insert into rhead values(1005,100); 1 row created. SQL> insert into rhead values(1006,100); 1 row created. SQL> insert into rhead values(1007,100); 1 row created.

9c.Create view from ticket_header with tno,origin,destination,rid

Creating table ticket_header SQL> create table ticket_header(tno number(5),rid number(3),origin varchar2(20),destination varchar2(20)); Table created. Inserting into table ticket_header SQL> insert into ticket_header values(100,10,'Coimbatore','Salem'); 1 row created. SQL> insert into ticket_header values(101,11,'Coimbatore','chennai'); 1 row created. Creating view SQL> create view ticketheadview(tno,rid,origin,destination)as select * from ticket_header; View created.

PROGRAM 10 Creation of table ticketdetail SQL> create table tdetail (tno number(5), amt number(12,2),destination varchar2(30),datesval date); Table created. Inserting values into ticketdetail SQL> insert into tdetail values(1000,450,'Hyderbad','12-feb-2009'); 1 row created. SQL> insert into tdetail values(1001,600,'Bombay','19-mar-2009'); 1 row created. SQL> insert into tdetail values(1002,250,'Chennai','2-apr-2009'); 1 row created.

PROGRAM 11 Creating table placehead SQL> create table placehead(place_id number(2),busstation char(30)); Table created. Inserting values into table placehead. SQL> insert into placehead values(01,'Chennai'); 1 row created. SQL> insert into placehead values(02,'bangalore'); 1 row created. SQL> insert into placehead values(03,'Coimbatore'); 1 row created. SQL> insert into placehead values(04,'Madurai'); 1 row created. SQL> insert into placehead values(05,'Trichi'); 1 row created. PL/SQL statement to update busstation values SQL> begin

2 update placehead set busstation='Erode' where place_id=01 or place_id=05; 3 end; 4 / PL/SQL procedure successfully completed. Creating table routedetail SQL> create table rou_detail(rid number(3), distance number(3), amount number (12, 2), day char(20)); Table created. SQL> insert into rou_detail values (100,10,12.34,'Monday'); 1 row created. PL/SQL to update the amount values SQL> declare 2 v_rid rou_detail.rid%type; 3 begin 4 update rou_detail set amount=200 where rid=&v_rid and distance<500; 5 end; 6 / Enter value for v_rid: 100 old 4: update rou_detail set amount=200 where rid=&v_rid and distance<500; new 4: update rou_detail set amount=200 where rid=100 and distance<500; PL/SQL procedure successfully completed. Trigger creation to not allow the transaction to happen on Saturday & sunday SQL> create or replace trigger btrig 2 before insert on rou_detail for each row 3 declare 4 begin 5 if:new.day='Sunday'then 6 raise_application_error(-20001,'Do transaction on some other day'); 7 end if; 8 if:new.day='Saturday'then 9 raise_application_error(-20001,'Do transaction on some other day'); 10 end if; 11 end; 12 /

Trigger created. Inserting values into routedetail SQL> insert into rou_detail values(1,2,13,'tuesday'); 1 row created. Trigger for deletion SQL> create or replace trigger mtrig 2 before delete on rou_detail 3 begin 4 raise_application_error(-20002,'All records will be deleted which can not be retrieved'); 5 end; 6 / Trigger created.

PROGRAM -12 Private Sub CmdAdd_Click() Adodc1.Recordset.AddNew MsgBox "records added" End Sub Public Sub CmdClear_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" End Sub Private Sub CmdDelete_Click() Adodc1.Recordset.Delete MsgBox "records deleted" End Sub Private Sub Cmdend_Click() End End Sub

Private Sub CmdMoveFirst_Click() Adodc1.Recordset.MoveFirst End Sub Private Sub CmdMoveLast_Click() If Not (Adodc1.Recordset.BOF) Then Adodc1.Recordset.MoveLast Else MsgBox "no records" End If End Sub Private Sub CmdMoveNext_Click() If Not (Adodc1.Recordset.EOF) Then Adodc1.Recordset.MoveNext Else MsgBox "no records" End If End Sub Private Sub CmdMovePrevious_Click() Adodc1.Recordset.MovePrevious End Sub Private Sub CmdUpdate_Click() Adodc1.Recordset.Update MsgBox "records updated" End Sub Private Sub display() Text1.Text = Adodc1.Recordset("rno") Text2.Text = Adodc1.Recordset("name") Text3.Text = Adodc1.Recordset("class") Text4.Text = Adodc1.Recordset("address") Text5.Text = Adodc1.Recordset("phno") End Sub Private Sub Form_Load() Form2.WindowState = 2 End Sub

SQL STATEMENTS SQL>create table stu_mas(rno varchar2(20),name varchar2(20),class varchar2(20),address varchar2(20),phno number(10)); Table created SQL> desc stu_mas; Name Null? Type ------------------------------- -------- ---RNO VARCHAR2(10) NAME VARCHAR2(20) CLASS VARCHAR2(20) ADDRESS VARCHAR2(20) PHNO NUMBER(10) SQL> insert into stu_mas values(114,'girija','bcom','thirunagar',9897654321); 1 row created.

SQL> insert into stu_mas values(115,'rajesh','bca','ashok nagar',9994654321); 1 row created. SQL> insert into stu_mas values(116,'harish','ecs','coimbatore',9897687124); 1 row created.

SQL> select * from stu_mas; RNO ---------114 115 101 NAME CLASS ADDRESS PHNO -------------------- -------------------- -------------------- --------girija bcom thirunagar 9.898E+09 rajesh bca ashok nagar 9.995E+09 harish ecs coimbatore 9.898E+09

Note: For connecting Oracle database 1. Goto start menusettingcontrol panelperformance and maintenanceadministrative toolsdata source(ODBC) 2. double click data source(ODBC): ODBC data source administrator opens 3. Select add from user DSN create new data source window appears select Microsoft ODBC for oracle. 4. Click finish. 5. Microsoft ODBC for oracle setup window appears with text areas 6. Fill DSN name, user name and server as any name , scott , oracle. 7. Click ok. 8. your DSN name appears in the user DSN tab 9. Click ok. 10. close the control panel. VB 1. 2. 3. 4. 5. Go to components and select Microsoft ADO Data Control 6.0(OLEDB) drag and drop the adodc control from tools of vb to from go to reference and select the following set the password as tiger and user name as scott in adodc property set the recordsource of adodc in adodc property(select the table name from oracle) 6. set the datafield and datasource for all the text boxes individually.

Вам также может понравиться