errores al generar aplicacion

01/02/2006 - 01:29 por jorge | Informe spam
Estoy desarrollando una aplicacion donde calculo la cantidad que se debe
pagar a un prestamo utilizando la funcion Pmt(), y el generador detecta una
serie de errores que acontinuacion muestro:

Private Sub TextBoxCantidadPrestada_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
TextBoxCantidadPrestada.TextChanged
If IsNumeric(TextBoxCantidadPrestada) Then
Cantidad = TextBoxCantidadPrestada
Else
MsgBox("Ingrese un valor numerico", vbCritical, "entrada de
datos erroneo")
TextBoxCantidadPrestada.SelectionStart = 0
TextBoxCantidadPrestada.SelectionLength =
Len(TextBoxCantidadPrestada)
cancel = True

End If
End Sub

Aqui en la linea donde fifura:

Cantidad = TextBoxCantidadPrestada

manifiesta el compilador que Un valor de tipo 'System.Windows.Forms.TextBox'
no se puede convertir en '2'.

y en la linea donde figura:

cancel = True

manifiesta el compilador que No se ha declarado el nombre 'cancel'.

SIENDO TODAS ESTAS LAS DECLARACIONES:

Dim Pagos As Double
Dim TipoInteres As Single
Dim duracion As Integer, Cantidad As Integer



Aqui en chkPagoanticipado manifiesta el compilador que no se ha declarado
"chkpagoanticipado"

Private Sub ButtonCalcular_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ButtonCalcular.Click
REM devuelve un tipo double que indica el pago de una anualidad
REM basada en pagos periodicos constantes con un tipo de interes
REM tambien constante
Pagos = Pmt(TipoInteres, duracion, -Cantidad, 0,
chkPagoanticipado.value)
MsgBox(Format$(Pagos, "#.00"), vbInformation, "Total de pagos")

End Sub
End Class


Private Sub TextBoxTipoInteres_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBoxTipoInteres.TextChanged
If IsNumeric(TextBoxTipoInteres) Then
TipoInteres = 0.01 * TextBoxTipoInteres / 12


Aqui el compilador manifiesta que El operador '*' no está definido para los
tipos 'Double' y 'System.Windows.Forms.TextBox'.


Disculpen lo extenso que he sido asi que lo dejo a su criterio las
correcciones del caso muchas gracias.

Preguntas similare

Leer las respuestas

#6 jorge
02/02/2006 - 22:38 | Informe spam
"Lucas" escribió:

Creo que el error está en la línea:

TextBoxCantidadPrestada.SelectionLength = Len(TextBoxCantidadPrestada)

porque el que no estés poniendo el ".Text" a "TextBoxCantidadPrestada" está
generando el error, pues no se puede calcular el tamaño del texto escrito.

prueba con:

TextBoxCantidadPrestada.SelectionLength = Len(TextBoxCantidadPrestada.Text)

También sería interesante que para que muestres mensajes uses el MessageBox,
en tu caso sería así:

MessageBox.Show("Ingrese un valor numerico", "Entrada de datos erronea",
MessageBoxButtons.OK, MessageBoxIcon.Error)

en vez del:

MsgBox("Ingrese un valor numerico", vbCritical, "entrada de datos erroneo")

Es solo una sugerencia, pero el MessageBox me parece más completo que el
MsgBox, al menos creo que puede recibir una mayor cantidad de argumentos y
por eso lo veo más completo.

Me avisas si te sirvió de algo lo que he escrito. Nos vemos.



Muchas gracias LUCAS, todo se genera satisfactoriamente, y se inicia muy
bien, ahora perdona esta consulta en este codigo que te pongo abajo es del
boton calcular:


Private Sub ButtonCalcular_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ButtonCalcular.Click
'devuelve un tipo double que indica el pago de una anualidad
'basada en pagos periodicos constantes con un tipo de interes
' tambien cinstante
Pagos = Pmt(TipoInteres, duracion, -Cantidad, 0,
CheckBoxPagoAnticipado.Visible)
MessageBox.Show(Format$(Pagos, "#.00"), "Total de pagos",
MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub

MI CONSULTA ES LA SIGUIENTE Y PERDONA TALVEZ ESTE ERRADO
cuando calculo:
12500 con un interes del 14.5%, con una duracion de 24 meses, en la
aplicacion que hemos desarrollado me sale la cantidad de 1440,83 ; segun el
ejercicio escrito en el libro el resultado debe ser : 603.12, estoy muy
satisfecho con tu apoyo, haber si me sacas de esta duda y gracias por tu
asesoramiento.
Respuesta Responder a este mensaje
#7 Lucas
02/02/2006 - 23:46 | Informe spam
El error creo que se debe a que uno de los parametros ingresados está mal
(creo que es el primero en este caso):

Para los datos que me haz dado debería ser así:

Pagos = Pmt(0.145 / 12, 24, -12500, 0)

Nota que el interés de 14.5% se pone en forma decimal y se tiene que dividir
entre
12. Pues (y es lo que asumo, porque mi respuesta conincide con la del libro)
el interés es anual y los pagos se hacen mensualmente (de ahí que se tenga
que dividir entre 12)

Espero que eso te haya ayudado, porque como te dije, mi respuesta coincide
con la del libro, así que el error debe ser el que te mencioné, es decir, el
primer parámetro está mal ingresado.

Me avisas si te sirvió de algo lo escrito. Nos vemos. Revisa lo siguiente:

Aquí te envío la descripción detallada de la función Pmt:

Public Shared Function Pmt ( _
Rate As Double, _
NPer As Double, _
PV As Double, _
<OptionalAttribute> Optional FV As Double = 0, _
<OptionalAttribute> Optional Due As DueDate = DueDate.EndOfPeriod _
) As Double

Parameters:

Rate
Required. Double specifies the interest rate per period. For example, if you
get a car loan at an annual percentage rate (APR) of 10 percent and make
monthly payments, the rate per period is 0.1/12, or 0.0083.

NPer
Required. Double specifies the total number of payment periods in the
annuity. For example, if you make monthly payments on a four-year car loan,
your loan has a total of 4 × 12 (or 48) payment periods.

PV
Required. Double specifies the present value (or lump sum) that a series of
payments to be paid in the future is worth now. For example, when you borrow
money to buy a car, the loan amount is the present value to the lender of the
monthly car payments you will make.

FV
Optional. Double specifying future value or cash balance you want after you
have made the final payment. For example, the future value of a loan is $0
because that is its value after the final payment. However, if you want to
save $50,000 during 18 years for your child's education, then $50,000 is the
future value. If omitted, 0 is assumed.

Due
Optional. Object of type DueDate Enumeration that specifies when payments
are due. This argument must be either DueDate.EndOfPeriod if payments are due
at the end of the payment period, or DueDate.BegOfPeriod if payments are due
at the beginning of the period. If omitted, DueDate.EndOfPeriod is assumed.

Return Value
Returns a Double specifying the payment for an annuity based on periodic,
fixed payments and a fixed interest rate.
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida