Académique Documents
Professionnel Documents
Culture Documents
Practical Solutions
for
Compiled by –
Sibtain Masih
Student of I.T. Department,
AP College,
Grant Road,
Mumbai – 400 008
Q.1. Create a project for Coffee Shop?
Form Design-
Code-
Option Explicit
Dim mcurSubTotal As Currency
Dim mcurTotal As Currency
Dim mcurGrandTotal As Currency
Dim mintCustomerCount As Integer
If IsNumeric(txtQuantity) Then
intQuantity = Val(txtQuantity)
curItemAmount = curPrice * intQuantity
mcurSubTotal = mcurSubTotal + curItemAmount
lblItemAmount = FormatCurrency(curItemAmount)
lblSubTotal = FormatNumber(mcurSubTotal)
lblTax = FormatNumber(curTax)
lblTotal = FormatCurrency(mcurTotal)
Else
MsgBox "Quantity must be numeric.", vbExclamation, "Numeric Test Failed"
txtQuantity = Empty
txtQuantity.SetFocus
End If
End Sub
'Add to totals
If mcurSubTotal <> 0 Then 'Should not be able add to counts if no new order/customer
'Preven accidential clicking
mintCustomerCount = mintCustomerCount + 1
End If
'Display appropriate display item and enable check box
With chkTax
.Enabled = True
.Value = vbChecked
End With
End Sub
Form Design-
Code-
mIncome = Val(txtIncome)
'Surcharge Calculation
If mIncome > 500000 Then
mSurcharge = mTax * 0.05
Else
mSurcharge = 0
End If
txtTax = mTax
txtSurcharge = mSurcharge
txtNetIncome = mIncome - (mTax + mSurcharge)
End Sub
End Sub
Screen Shot-
Q.3. Create a project to read the marks of I, II, III and IV semester of B.Sc.(I.T.) students
and calculate total and average?
Form Design-
Code-
End Sub
Form Design-
Code-
cbo1.AddItem "Apple"
cbo1.AddItem "Mango"
cbo1.AddItem "Grapes"
cbo1.AddItem "Banana"
End Sub
Screen Shot-
Q.5. Create a project to maintain form no, name, percentage, maths marks and category
of students in a random file. Create a user defined type for maintaining the details. Allow
the user to ADD, MOODIFY and DELETE details. Use a list box to display the name of
the student to the user. Provide a SHOW button to display all the details in text boxes
after selecting the name from the list?
Form Design-
Code-
Option Explicit
Private Type Student
curFormNo As Currency
strName As String * 10
curPercentage As Currency
curMathsMarks As Currency
strCategory As String * 5
End Type
Dim mudtStudent As Student
For i = 1 To 5
If Trim(mudtStudent.strName) = Trim(lstName.List(lstName.ListIndex)) Then
txtFormNo = mudtStudent.curFormNo
txtPercentage = mudtStudent.curPercentage
txtMathsMarks = mudtStudent.curMathsMarks
txtCategory = mudtStudent.strCategory
For i = 1 To 5
Get #1, i, mudtStudent
End Sub
Form Design-
Code-
Form Design-
Code-
Option Explicit
Dim mintCounter As Integer
Dim mcurAmount As Currency
Dim mcurPrizeAmoutn As Currency
Dim intQuestionNumber As Integer, intRandom As Integer, i As Integer
Dim strName As String, strNum As String
Dim mintarrQuestionNumber(15) As Integer
End If
End Sub
With optB
.Value = False
.Visible = True
.Enabled = True
End With
With optC
.Value = False
.Visible = True
.Enabled = True
End With
With optD
.Value = False
.Visible = True
.Enabled = True
End With
lblOptA.Visible = True
lblOptB.Visible = True
lblOptC.Visible = True
lblOptD.Visible = True
cmdLock.Enabled = True
mintCounter = mintCounter + 1
If mintCounter = 14 Then
MsgBox "Final Question for 1 Crore - Are You Ready !!!", vbOKOnly +
vbInformation, "KBC III"
End If
SetQuestion
SetCurrentQuestionColor
SetPreviousQuestionColor
cmdNext.Enabled = False
End Sub
Fuel charge is 10.5% of gross amount, electricity duty is 5% of gross amount plus fuel
charges, service tax is 2.6% of gross amount plus fuel charges plus electricity duty and
net amount is gross amount + fuel charges + electricity duty + service tax.
Display first due date after one month from bill date.
Display second due date after two months from bill date with interest 12% added.
Display third due date after three months from bill date with interest 24%.
Provide facility for bill printing?
Form Design-
Code-
Option Explicit
Dim mCurMeterReading As Integer, mPrevMeterReading As Integer, mUnitsConsumed
As Integer, mDeposit As Integer
Dim mElectricityCharge As Double, mGrossAmt As Double, mFuelCharges As Double,
mElectricityDuty As Double, mServiceCharge As Double, mNetAmt As Double,
mNetAmtAfter1mMonth As Double, mNetAmtAfter2mMonths As Double,
mNetAmtAfter3mMonths As Double
Dim mDate As Date
Private Sub cmdCalculate_Click()
mCurMeterReading = Val(txtCurrentMeterReading)
mPrevMeterReading = Val(txtPreviousMeterReading)
mUnitsConsumed = mCurMeterReading - mPrevMeterReading
If cboConsumerType.ListIndex = 0 Then
mDeposit = 100
End If
mNetAmtAfter1mMonth = mNetAmt
mNetAmtAfter2mMonths = mNetAmt + mNetAmt * 0.12
mNetAmtAfter3mMonths = mNetAmt + mNetAmt * 0.24
mDate = txtDate
txtUnitsConsumed = FormatNumber(mUnitsConsumed, 2)
txtDeposit = FormatNumber(mDeposit, 2)
txtElectricityCharge = FormatNumber(mElectricityCharge, 2)
txtGrossAmt = FormatNumber(mGrossAmt, 2)
txtFuelCharges = FormatNumber(mFuelCharges, 2)
txtElectricityDuty = FormatNumber(mElectricityDuty, 2)
txtServiceCharge = FormatNumber(mServiceCharge, 2)
txtNetAmt = FormatNumber(mNetAmt, 2)
txt1DueDateAmt = FormatNumber(mNetAmtAfter1mMonth, 2)
txt2DueDateAmt = FormatNumber(mNetAmtAfter2mMonths, 2)
txt3DueDateAmt = FormatNumber(mNetAmtAfter3mMonths, 2)
End Sub
End Sub
Screen Shot-
Q.9. Create a project to read matrix A(x,y) and matrix B(p,q). Calculate and print matrix
Result. Display matrix subscript while inputting and printing. Check if matrix
multiplication is possible. If not then display appropriate message?
Form Design-
Code-
Option Explicit
Dim matrixA(10, 10) As Integer, matrixB(10, 10) As Integer, matrixC(10, 10)
Dim intRowA As Integer, intColA As Integer, intRowB As Integer, intColB As Integer, i
As Integer, j As Integer, k As Integer, m As Integer
lblResult = lblResult & "(" & i + 1 & "," & j + 1 & ") "
lblResult = lblResult & matrixC(i, j) & " "
Next
lblResult = lblResult + vbNewLine + vbNewLine
Next
For i = 0 To row - 1
For j = 0 To col - 1
matrixC(i, j) = 0
Next
Next
End Function
&File Menu
-&points
-&sumarry
-&exit
&Edit Menu
-&clear
-&font
-&color
&Help
-&About
Use text boxes to obtain the readers name and number of books read. Use a label to
display the number of bonus points. The point’s menu command should call a function
procedure to calculate the points using this schedule.
The first 3 books are worth 10 points each.
The next 3 books are worth 15 points each.
All books over 6 are worth 20 points each.
The summary menu command displays the average number of books read for all readers
of that session.
The clear menu command clears the name, no. of books read and the bonus points and
then reset the focus.
The color and font menu command change the color and font of information displayed in
the bonus point label.
Use a message box to displayed your name as a programmer for the about option on the
help menu?
Form Design-
Code-
lblBonusPoints.Font.Name = cdbDialog.FontName
lblBonusPoints.Font.Bold = cdbDialog.FontBold
lblBonusPoints.Font.Italic = cdbDialog.FontItalic
lblBonusPoints.Font.Size = cdbDialog.FontSize
lblBonusPoints.Font.Strikethrough = cdbDialog.FontStrikethru
lblBonusPoints.Font.Underline = cdbDialog.FontUnderline
lblBonusPoints.ForeColor = cdbDialog.Color
End Sub
If br <= 3 Then
BonusCalculation = 10 * br
ElseIf br <= 6 Then
BonusCalculation = 10 * 3 + 15 * (br - 3)
Else
BonusCalculation = 10 * 3 + 15 * 3 + 20 * (br - 6)
End If
End Function
Screen Shot-
Compiled by –
Sibtain Masih
Student of I.T. Department,
AP College,
Grant Road,
Mumbai – 400 008