Cita:
Iniciado por ElPadrino
Error "13" en linea de tiempo
no coinciden los tipos
este es el codigo
ACLARACIONES:
Cuando vas a tomar el valor de un textbox siempre tenes que tranformar al tipo de variable a la que vas a asignar...
No es necesario el .text...
EJ:
A = cdbl(Text1)
Vos pones A = cdbl(Tex1.Text)
----------------------------------------------------------------------------------
Muy bien, si vas a manejar MONEDA, la variable es CURRENCY, y al asignar el valor a la variable del text seria ccur(text1)
----------------------------------------------------------------------------------
Es OBVIO que si vas a manejar monedas, en tus textbox solo tengas NUMEROS Y EL SIMBOLO DECIMAL CONFIGURADO EN LA CONFIGURACION REGIONAL (te maree?)
Inicio -----> Configuracion ------> Panel de control -----> Configuracion regional
Click en el boton "Personalizar"
y ahi dice "SIMBOLO DECIMAL", si es una "," en tus textbox tenes que trabajar con ",", si es un "." en tus textbox tenes que trabajar con "."
Si vos en un textbox tenes el valor "HOLA" y queres sumarlo, obvio que te tira error de que no coinciden los tipos...
(tambien tira error si dejas vacio)
------------------------------------------------------------------------------------
Eso de crear 10000 textbox, y 10000 variables con el nombre
TextBox1
TextBox2
TextBox3
..........
TextBoxN
Es una boludes....
Para algo existen las matrices de controles y de variables...
Cuando copias y pegas un TextBox te pregunta "Desea crear una matriz de controles?), le pones que si... y vas a tener asi "TextBox(Index)" donde index es el identificador de tu textbox para diferenciarlo de los demas de la matris.
TextBox(0)
TexBoxt(1)
TextBox(2)
................
TextBox(N)
Tu cabeza debe estar pensando "es lo mismo, solo que el numero va entre los parentesis"...
No es lo mismo....
Por que si vos queres sumar 10 textbox seguidos, usas un for, ejemplo
Código:
Dim Suma as Currency
Dim X as Integer
For X = 0 to 9
Suma = Suma + Ccur(TextBox(X))
Next X
Y te evitaste hacer el:
Código:
Dim Suma as Currency
Suma = CCur(TextBox1) + CCur(TextBox2) + CCur(TextBox3) + CCur(TextBox4) + CCur(TextBox5) + CCur(TextBox6) + CCur(TextBox7) + CCur(TextBox8) + CCur(TextBox9) + CCur(TexBox9)
¿Cual de los dos es mas OPTIMO y logicamente mejor
---------------------------------------------------------------------------------------
En fin, la programacion no es para cualquiera.
Que se sientan ofendidos a los que le llego mi mensaje.
EDITO: Pa demostrarlo mejor por que arriba no se noto tanto...
Como haces para sumar 100 TextBox...
Si seguimos tu idea seria...
Código:
Dim Suma as Currency
Suma = Ccur(TextBox1) + Ccur(TextBox2) + Ccur(TextBox3) + Ccur(TextBox4) + Ccur(TextBox5) + Ccur(TextBox6) + Ccur(TextBox7) + Ccur(TextBox8) + Ccur(TextBox9) + Ccur(TextBox10) + Ccur(TextBox11) + Ccur(TextBox12) + Ccur(TextBox13) + Ccur(TextBox14) + Ccur(TextBox15) + Ccur(TextBox16) + Ccur(TextBox17) + Ccur(TextBox18) + Ccur(TextBox19) + Ccur(TextBox20) + Ccur(TextBox21) + Ccur(TextBox22) + Ccur(TextBox23) + Ccur(TextBox24) + Ccur(TextBox25) + Ccur(TextBox26) + Ccur(TextBox27) + Ccur(TextBox28) + Ccur(TextBox29) + Ccur(TextBox30) + Ccur(TextBox31) + Ccur(TextBox32) + Ccur(TextBox33) + Ccur(TextBox34) + Ccur(TextBox35) + Ccur(TextBox36) + Ccur(TextBox37) + Ccur(TextBox38) + Ccur(TextBox39) + Ccur(TextBox40) + Ccur(TextBox41) + Ccur(TextBox42) + Ccur(TextBox43) + Ccur(TextBox44) + Ccur(TextBox45) + Ccur(TextBox46) + Ccur(TextBox47) + Ccur(TextBox48) + Ccur(TextBox49) + Ccur(TextBox50) + Ccur(TextBox51) + Ccur(TextBox52) + Ccur(TextBox53) + Ccur(TextBox54) + Ccur(TextBox55) + Ccur(TextBox56) + Ccur(TextBox57) + Ccur(TextBox58) + Ccur(TextBox59) + Ccur(TextBox60) + Ccur(TextBox61) + Ccur(TextBox62) + Ccur(TextBox63) + Ccur(TextBox64) + Ccur(TextBox65) + Ccur(TextBox66) + Ccur(TextBox67) + Ccur(TextBox68) + Ccur(TextBox69) + Ccur(TextBox70) + Ccur(TextBox71) + Ccur(TextBox72) + Ccur(TextBox73) + Ccur(TextBox74) + Ccur(TextBox75) + Ccur(TextBox76) + Ccur(TextBox77) + Ccur(TextBox78) + Ccur(TextBox79) + Ccur(TextBox80) + Ccur(TextBox81) + Ccur(TextBox82) + Ccur(TextBox83) + Ccur(TextBox84) + Ccur(TextBox85) + Ccur(TextBox86) + Ccur(TextBox87) + Ccur(TextBox88) + Ccur(TextBox89) + Ccur(TextBox90) + Ccur(TextBox91) + Ccur(TextBox92) + Ccur(TextBox93) + Ccur(TextBox94) + Ccur(TextBox95) + Ccur(TextBox96) + Ccur(TextBox97) + Ccur(TextBox98) + Ccur(TextBox99) + Ccur(TextBox100)
Si seguimos mi idea seria (obviamente creando una matris de controles textbox
Código:
Dim Suma as Currency
Dim X as Integer
For X = 0 to 99
Suma = Suma + Ccur(TextBox(X))
Next X
Cuack. Ahi si se noto la diferencia