|
-
Jun 12th, 2000, 07:35 AM
#1
Thread Starter
Hyperactive Member
Here is a snippet of my code for a financial calculator program. The Val(lstInterest.Text) works if the interest rate does not contain a number after the decimal point. (7.00%) However, if the text contains a number (7.25%), then I get a type mismatch error.
Any Ideas???
Code:
Dim MonPmt As Double, dblRate As Double, intPmts As Integer, dblPrncpl As Double
Public Sub Interest()
dblPrncpl = txtPrincipal.Text
dblRate = Val(lstInterest.Text)
dblRate = dblRate / 100
MonPmt = Pmt(dblRate / 12, intPmts, -dblPrncpl)
lblPayment = Format(MonPmt, "$###,###,##0.00")
End Sub
Private Sub cmdCalc_Click()
Interest
End Sub
Private Sub Form_Load()
frmMthlyPay.Left = (Screen.Width - frmMthlyPay.Width) / 2
frmMthlyPay.Top = (Screen.Height - frmMthlyPay.Height) / 2
End Sub
Private Sub mnuFileExit_Click()
End
End Sub
Private Sub mnuFilePrint_Click()
frmMthlyPay.PrintForm
End Sub
Private Sub mnuFormatBackground_Click()
dlgCommon.Flags = cdlCCRGBInit
dlgCommon.ShowColor
frmMthlyPay.BackColor = dlgCommon.Color
End Sub
Private Sub mnuFormatFont_Click()
dlgCommon.Flags = cdlCFBoth
dlgCommon.FontName = lblPayment.FontName
dlgCommon.FontBold = lblPayment.FontBold
dlgCommon.FontItalic = lblPayment.FontItalic
dlgCommon.FontSize = lblPayment.FontSize
lblPayment.FontName = dlgCommon.FontName
lblPayment.FontBold = dlgCommon.FontBold
lblPayment.FontItalic = dlgCommon.FontItalic
lblPayment.FontSize = dlgCommon.FontSize
dlgCommon.ShowFont
End Sub
Private Sub mnuFormatInfo_Click()
dlgCommon.Flags = cdlCCRGBInit
dlgCommon.ShowColor
fraInfo.BackColor = dlgCommon.Color
End Sub
Private Sub optTerm_Click(Index As Integer)
Select Case Index
Case 0
intPmts = 24
Case 1
intPmts = 36
Case 2
intPmts = 48
Case 3
intPmts = 60
End Select
End Sub
-
Jun 12th, 2000, 07:48 AM
#2
transcendental analytic
Where exactly? Type mismatches are very easy to track and get rid of, but i don't have your project so i can't tell you
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 12th, 2000, 07:54 AM
#3
Thread Starter
Hyperactive Member
It is on this line:
Code:
dblRate = Val(lstInterest)
The variable creating the problem contains a percentage number with more than a zero after the problem. There is no error message if the user inputs say 7.00%. But if the input is 7.25% then there is a type mismatch.
Hmmm
Thanks for the help,
Sal
-
Jun 12th, 2000, 08:04 AM
#4
transcendental analytic
It doesn't accept the "%" so you can do this:
dblRate = Val(left(lstInterest,len(lstInterest)-1))
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|