CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    1

    NEED QUICK HELP IN VB6

    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.




  2. #2
    Join Date
    Apr 2001
    Location
    Wisconsin, USA
    Posts
    150

    Re: NEED QUICK HELP IN VB6

    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






  3. #3
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    Re: NEED QUICK HELP IN VB6

    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





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured