You are on page 1of 19

1.

Development of an application to create arithmetic calculator Code Option Explicit Dim prev_num Dim curr_num Dim sign Private Sub cmdCos_Click() lblDisplay.Caption = Cos(Val(lblDisplay.Caption)) End Sub Private Sub cmdCqrt_Click() lblDisplay.Caption = Val(lblDisplay.Caption) ^ (1/3) End Sub Private Sub cmdEqual_Click() If sign = "pow" And prev_num <> "" And lblDisplay.Caption <> "" Then lblDisplay.Caption = prev_num ^ lblDisplay.Caption End If End Sub Private Sub cmdExp_Click() lblDisplay.Caption = Exp(Val(lblDisplay.Caption)) End Sub Private Sub cmdFive_Click() If lblDisplay.Caption = "" Or lblDisplay.Caption = "0" Then lblDisplay.Caption = "5" ElseIf lblDisplay.Caption <> "" Then lblDisplay.Caption = lblDisplay.Caption & "5" End If End Sub Private Sub cmdFour_Click()

If lblDisplay.Caption = lblDisplay.Caption & "1" End If End Sub .Caption = "" Or lblDisplay.Caption <> "" Then lblDisplay.Caption = lblDisplay.Caption = Log(Val(lblDisplay.Caption = "4" ElseIf lblDisplay.Caption = "0" Then lblDisplay.Caption & "9" End If End Sub Private Sub cmdOne_Click() If lblDisplay.Caption = "" Or lblDisplay.Caption <> "" Then lblDisplay.Caption = "8" ElseIf lblDisplay.Caption = "0" Then lblDisplay.Caption = Log(Val(lblDisplay.Caption & "8" End If End Sub Private Sub cmdLn_Click() lblDisplay.Caption = "9" ElseIf lblDisplay.Caption = "0" Then lblDisplay.Caption = "" Or lblDisplay.Caption = lblDisplay.Caption & "4" End If End Sub Private Sub cmdHeight_Click() If lblDisplay.Caption = "0" Then lblDisplay.Caption)) / Log(Exp(1)) End Sub Private Sub cmdLog_Click() lblDisplay.Caption)) End Sub Private Sub cmdNine_Click() If lblDisplay.Caption <> "" Then lblDisplay.Caption = "" Or lblDisplay.Caption = lblDisplay.Caption <> "" Then lblDisplay.Caption = "1" ElseIf lblDisplay.

Caption)) End Sub Private Sub cmdSix_Click() If lblDisplay.Caption <> "" Then lblDisplay.Caption & ".Caption = Sin(Val(lblDisplay.Caption = lblDisplay.Caption = prev_num ^ curr_num End If End Sub Private Sub cmdSeven_Click() If lblDisplay.Caption <> "" Then lblDisplay.Caption) lblDisplay.Caption = "6" ElseIf lblDisplay.Caption = lblDisplay.Caption = "0" ElseIf curr_num = "" Then curr_num = Val(lblDisplay.Private Sub cmdPoint_Click() If lblDisplay.Caption = "" Or lblDisplay.Caption = "7" ElseIf lblDisplay.Caption <> "" Then lblDisplay.Caption & "6" End If End Sub .Caption & "7" End If End Sub Private Sub cmdSin_Click() lblDisplay." End If End Sub Private Sub cmdPower_Click() sign = "pow" If prev_num = "" Then prev_num = Val(lblDisplay.Caption = "" Or lblDisplay.Caption = "0" Then lblDisplay.Caption) lblDisplay.Caption = lblDisplay.Caption = "0" Then lblDisplay.

Caption & "0" End If End Sub Private Sub Command1_Click() lblDisplay.Caption = lblDisplay.Caption & "2" End If End Sub Private Sub cmdZero_Click() If lblDisplay.Caption)) End Sub Private Sub cmdThree_Click() If lblDisplay.Caption = lblDisplay.Caption = Val(lblDisplay.Caption & "3" End If End Sub Private Sub cmdTwo_Click() If lblDisplay.Caption ElseIf lblDisplay.Caption = "0" curr_num = "" prev_num = "" End Sub Interface showing the cube root of 8 .Caption <> "0" Then lblDisplay.Caption = "" Or lblDisplay.Caption = "0" Then lblDisplay.Caption = cmdZero.Caption = "2" ElseIf lblDisplay.Private Sub cmdSquare_Click() lblDisplay.Caption) ^ 2 End Sub Private Sub cmdTan_Click() lblDisplay.Caption <> "" Then lblDisplay.Caption <> "" Then lblDisplay.Caption = "3" ElseIf lblDisplay.Caption = "0" Then lblDisplay.Caption = "0" Then lblDisplay.Caption = Tan(Val(lblDisplay.Caption = "" Or lblDisplay.Caption = "" Or lblDisplay.Caption = lblDisplay.Caption <> "" And lblDisplay.

Text = rtBox1.Italic = True End Sub Private Sub mnuLower_Click() rtBox2. left move.Text = rtBox1.2. changing font style. size and so on.Text rtBox2.Bold = True End Sub Private Sub mnuItalic_Click() rtBox2.Text rtBox2. right move.Font. lower case. Design an application using menus to manipulation on string like changing upper case.Font. Code Private ForeColors(0 To 3) As Long Option Explicit Private Sub Label1_Click() End Sub Private Sub mnuBold_Click() rtBox2.Text) End Sub . color.Text = LCase(rtBox1.

Text = UCase(rtBox1.Private Sub mnuNormal_Click() rtBox2.Text rtBox2.Size = 20 End Sub Private Sub mnuUpper_Click() rtBox2.Text rtBox2.Text = rtBox1.Italic = False End Sub Private Sub mnuSize_Click() rtBox2.Font.Font.Text) End Sub Private Sub rtBox1_Change() End Sub Interface .Font.Text = rtBox1.Bold = False rtBox2.

X As Single. Develop an application to display text “Hello” at any place the left mouse button clicked.3. Code Option Explicit Private Sub Form_MouseDown(Button As Integer. Y As Single) If Button = 1 Then Form1.Print "Hello" End If End Sub Interface . Shift As Integer.

quantity. address. Develop an application using data control to design inventory control fields like supplier number.4. supplier name. price and total prices Database design Interface design .

5. amount. current reading.Val(txtPrevReading) lblUnits.Text) . previous reading. Prepare electricity bill using ado control fields like customer number.Caption = units & " KW" lblAmount = units * 15 & " Frw" End Sub Private Sub cmdClear_Click() . units. customer name. Code Option Explicit Private Sub cmdCalculate_Click() Dim units units = Val(txtCurrReading.

Enabled = False txtCurrReading.Enabled = False Else txtPrevReading.Enabled = False txtCurrReading.Enabled = False End Sub Private Sub txtCurrReading_Change() If txtCurrReading = "" Then cmdCalculate.Enabled = True End If End Sub Private Sub txtNumber_Change() If txtNumber = "" Then txtName.Enabled = False Else cmdCalculate.txtNumber.Enabled = False txtPrevReading.Enabled = False txtCurrReading.Text = "" txtPrevReading.Text = "" txtPrevReading.Enabled = False cmdCalculate.Enabled = False txtName.Enabled = True End If End Sub Private Sub txtName_Change() If txtName = "" Then txtPrevReading.Enabled = False txtPrevReading.Text = "" txtCurrReading.Text = "" cmdCalculate.Text = "" txtName.Enabled = False txtPrevReading.Text = "" lblUnits.Caption = "" lblAmount.Caption = "" End Sub Private Sub Form_Load() txtName.Text = "" txtCurrReading.Text = "" txtCurrReading.Text = "" .

Enabled = False Else txtCurrReading.Enabled = False txtCurrReading. Write a menu driven program to Crete Telephone Directory Maintenance Report Field Details: Custno Integer Customer Number Custname Text(25) Customer Name Doorno Text(5) Door Number Street Text(25) Name of the street City Text(10) Name of the City Pincode Integer Pincode Phno Integer Phone Number Area Text(20) Area .Enabled = False Else txtName.Text = "" cmdCalculate.cmdCalculate.Enabled = True End If End Sub Interface 6.Enabled = True End If End Sub Private Sub txtPrevReading_Change() If txtPrevReading = "" Then txtCurrReading.

Recordset.Recordset.Text Data1.Recordset.Recordset.Recordset.Refresh End Sub Private Sub mnuEdit_Click() op = "e" Data1.Recordset.Fields("city") = Text5.AddNew End Sub Private Sub mnuSave_Click() If op = "n" Then Data1.Recordset.Fields("customername") = Text2.Recordset.Fields("phonenr") = Val(Text8.Delete Data1.Text Data1.Text Data1.Update Data1.Edit End Sub Private Sub mnuNew_Click() op = "n" Data1.Text) Data1.Recordset.Text) Data1.Fields("customernr") = Val(Text1.Fields("street") = Text4.Refresh End If End Sub Interface .Recordset.Text) Data1.Code Option Explicit Dim op Private Sub mnuDelete_Click() Data1.Fields("pincode") = Val(Text6.Fields("area") = Text7.Text Data1.Refresh ElseIf op = "e" Then Data1.Recordset.Text Data1.Fields("doornr") = Text3.Recordset.

a Combobox having the list of all trains departing form Chennai is to be listed (ii) After the user selects the train of his choice from the ComboBox.7. second class fare and unreserved class fare should be displayed in the Text Box. Allepey Express . details of the selected train such as departure time. Develop an application using two tabstrips defined by the following specifications (i) On Clicking tabstrip1. Chennai Mail. Howrath Mail. and clicks tabstrip2. Controls Tabstrip Tabstrip ComboBox Property Tabs(Caption) Tabs(Caption) List Settings Train List Train Details Bangalore Mail. first class fare. Also place four labels to depict the train details and a control array of four textboxes.

Visible = False Label2.Visible = True Label4.Visible = False Label4.Visible = False End Sub Private Sub SSTab1_Click(PreviousTab As Integer) cmbTrainsList.Visible = True Label2.Visible = False Text1(2).Visible = True Text1(2).Visible = False Data1.Visible = False cmbTrainsList.Text & "'" Data1.Visible = True If cmbTrainsList.Visible = True End Sub Private Sub SSTab2_Click(PreviousTab As Integer) Text1(0).Visible = False Label5.Text <> "" Then Data1.Visible = False Text1(1).Visible = True Label5.Visible = True Label3.RecordSource = "select * from traindetails where trainName='" & cmbTrainsList.Visible = True Text1(3).Visible = False Label3.Visible = False Text1(3).Refresh End If End Sub .Visible = True Text1(1).Code Private Sub cmbTrainsList_Change() End Sub Private Sub Form_Load() Text1(0).

List Box and Picture Box. it should take the user to the document which accepts the following details: (i) Train No (ii) Train Name (iii) Destination Point (iv) Departure Time and the results should be saved in a text file called “Traindetails.Show End Sub .txt” Code of two command buttons on User document form Private Sub cmdAcceptPassenger_Click() frmPassenger.txt” When Accept Passenger Details is clicked. it should take the user to the document which accepts the following details: (i) Passenger Name (ii) Train Name (iii) Sex (iv) Age (v) Address (vi) Classs and the results should be saved in a text file called “passsdetails. ComboBox. When Accept Train Details is clicked. 10. Create an user document which has two command buttons with captions (i) Accept Train Details (ii) Accept Passenger Details.Interface 8. Hjhjjhj 9. Write a clipboard program that uses cut. copy and paste operations and contains a TextBox.

Text ts.txt" Set fs = New FileSystemObject .OpenTextFile(fileName.Write " " & txtTrainName.Text ts.WriteLine "" ts.txt” file Private Sub cmdDone_Click() Dim fileName As String Dim fs As FileSystemObject Dim ts As TextStream fileName = "C:\Users\mm\Desktop\vbassignment\Q10\Traindetails.FileExists(fileName) Then fs.Text ts.txt" Set fs = New FileSystemObject If Not fs.Write " " & txtDepartureTime.Close End If Set ts = Nothing Set fs = Nothing End Sub Code to create “passsdetails.CreateTextFile (fileName) Set ts = fs.Show End Sub Code to create “Traindetails.Write txtTrainNumber.Private Sub cmdAcceptTrain_Click() frmTrain.txt” file Private Sub cmdDone_Click() Dim fileName As String Dim fs As FileSystemObject Dim ts As TextStream fileName = "C:\Users\mm\Desktop\vbassignment\Q10\Traindetails.Text ts.Write " " & txtDestinationPoint. ForAppending. True) ts.

CreateTextFile (fileName) Set ts = fs.Text ts.OpenTextFile(fileName.Text ts.WriteLine "" ts. ForAppending.Text ts.FileExists(fileName) Then fs.Write " " & txtDestinationPoint.If Not fs. User document 2.Text ts.Write " " & txtTrainName.Write txtTrainNumber.Write " " & txtDepartureTime. Accept train’s details Form . True) ts.Close End If Set ts = Nothing Set fs = Nothing End Sub Interfaces: 1.

3. Created file.txt) 4. Accept passenger’s details Form . with train’s details after “Done” button is clicked (Traindetails.

5. Created file.txt) . with passenger’s details after “Done” button is clicked (passsdetails.

90/10 997.   70.8 99          ...1907 430 -:99438.3 8/09.0/ %7.880307 8/09.0595.3/09.8472  .8.

888/09..1907 430 -:99438.8.90/10 95.880307 8/09.0/ 5.8 99    .    70.