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




Reply With Quote