Click to See Complete Forum and Search --> : NEED QUICK HELP IN VB6
tch1
June 13th, 2001, 07:57 AM
I need help writing codes for 2 programs in Visual Basic 6.
The first one has to be done in the Select Case format and the second one has to be done in the Loop format.
1. Program the decision using Select Case statements. Write a program that request an exam score and assigns a letter grade with the scale 90-100(A), 80-89(B), 70-79(C), 60-69(D), 0-59(F).
2. A TV set is purchased with a loan of $563 to be paid off with five monthly payments of $116. The interest rate is 1 percent per month. Display a table giving the balance on the loan at the end of each month.
Spectre5000
June 13th, 2001, 08:05 AM
Program 1:
Select Case intScore
Case is > 89
strGrade = A
Case is > 79
strGrade = B
Case is > 69
strGrade = C
Case is > 59
strGrade = D
Case else
strGrade = F
End Select
Cubbie
June 14th, 2001, 11:46 AM
Program 2:
This a is quick idea of how to do it. Put a command button and a standard grid on a form and use the code below. When you click on the command button it will populate the grid with the balance, amount paid on principle, and amount paid in interest.
NOTE: Due to rounding it may be a off a penny.
private Sub Command1_Click()
Dim i as Integer
Dim rate as string
Dim bal as string
Dim pay as string
Dim interest as string
Dim prince as string
rate = ".01"
rate = Format$(rate, "0.00")
pay = "116.00"
pay = Format$(pay, "0.00")
bal = "563.00"
bal = Format$(bal, "0.00")
'Widen grid columns
for i = 0 to 2
Grid1.ColWidth(i) = 750
next
' First column shows initial balance and balance after each payment
' Second column shows amount paid on principle for each payment
' Third Column shows amount paid in interest for each payment
'Loops to populate each row with data in three columns
for i = 0 to 4
'Balance (col 1)
Grid1.Col = 0
Grid1.Row = i
Grid1.Text = Format$(bal, "0.00")
interest = Format$(rate * bal, "0.00")
'Priciple payment (col 2)
Grid1.Col = 2
Grid1.Row = i
Grid1.Text = interest
prince = Format$("116.00" - interest, "0.00")
'Interest payment (col 3)
Grid1.Col = 1
Grid1.Row = i
Grid1.Text = prince
bal = bal - prince
next
End Sub
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.