VBA programming

posted by .

How to get isnumeric function to display an "error" message when necessary.

Sub DetermineinterestSelectCase()
Dim loan As Variant
Dim interest As Double
loan = InputBox("Enter your desired loan amount, from 1 dollar to 5 million dollars.")
Select Case loan
Case IsNumeric(loan) = False: MsgBox ("Error")
Case Is < 1000000: interest = ".08"
Case 1000000 To 4000000: interest = ".10"
Case Is > 4000000: interest = ".11"
End Select
MsgBox ("The loan amount was " & loan & " with an interest rate of " & interest & "")
End Sub

Sub DetermineinterestIf()
Dim loan As Variant
Dim interest As Double
loan = InputBox("Enter your desired loan amount, from 1 dollar to 5 million dollars.")
IsNumeric (loan)
If loan < 1000000 Then interest = ".08"
If loan > 4000000 Then interest = ".11"
If 1000000 < loan < 4000000 Then interest = ".10"
MsgBox ("The loan amount was " & loan & " with an interest rate of " & interest & ".")
End Sub

  • VBA programming -

    IsNumeric(s) returns true or false.
    It's up to you to handle each case.

    If IsNumeric(s) then
    MsgBox(msg)
    else
    do other stuff
    end if

  • VBA programming -

    Oops - make that

    If Not IsNumeric(s) Then
    ...

    to handle the error case.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. programming

    write a program to calculate the amount of a server's tip given the amount of the bill and the percentage tip ovtained via input dialog boxes. The output should be a complete sentence that reiterates the inputs and gives the resulting …
  2. Programming

    I’m using VB 2008. I need to write a simple program that calculates total sales of purchases. The program should accept item costs as input calculate the tax on each item (8%) display the item cost, total cost, and total after taxes. …
  3. eco

    Suppose a person pays $80 of annual interest on a loan that has a 5 percent annual interest rate. The loan amount is: A. $400. B. $1,600. C. $160. D. $85. 10. Suppose a loan customer is considering two alternative $22,000 loans. Loan …
  4. math

    Loan #1 Year Amount owed 1 $3796 2 $3942 3 $4088 Loan # 2 Year Amount owed 1 $977.53 2 $1036.18 3 1098.35 For loan #1 is simple interest. Loan #2 is compound interest How much was each loan originally Determine the future value of …
  5. math

    Loan #1 Year Amount owed 1 $3796 2 $3942 3 $4088 Loan # 2 Year Amount owed 1 $977.53 2 $1036.18 3 1098.35 For loan #1 is simple interest. Loan #2 is compound interest How much was each loan originally Determine the future value of …
  6. VBA Programming

    I'm trying to create a macro that asks for a loan between 1 dollar and 5 million, and returns different interest rates based on the amount of the loan. For some reason when I type in different loan amounts it automatically makes my …
  7. Vba

    I'm trying to write a sub that asks how much oil I made, and then gives me number of barrels needed to hold oil, cost of producing oil, and profit from oil. This is what I have so far, I'm not sure what to do. Sub Oil() Dim barrels …
  8. Computer Programming

    I'm trying to create a vba code that solves this problem: 50 apartment units rent for 600 a month, for each 40 dollar increase in rent a unit becomes unoccupied. I want to find the max profit and number of units at that number. Sub …
  9. Math

    What is the amount of interest on the loan?
  10. Visual Basic

    how to use formula b=p (1+r)^n, to calculate annual interests for a savings account in visual basic project This is my code so far>>>>>>>>>>>>>> Option Explicit On Option Strict On Option Infer …

More Similar Questions