Problema con signo de variable en input
Publicado: 30 Mar 2009, 17:03
como hago para que en un input me reconozca los numeros negativos???, porque si pongo -1 al multiplicarlo no lo multiplica no se que salio mal....
este es el codigo completo:
Gracias de antemano
este es el codigo completo:
Gracias de antemano
Código: Seleccionar todo
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#AutoIt3Wrapper_outfile=Calc2Grado.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
Opt('MustDeclareVars', 1)
Calculadora()
Func Calculadora()
Local $TA, $Calculo, $TB, $TC, $VA, $VB, $VC, $VX1, $VX2, $TX1, $TX2, $BC, $BR, $msg
GUICreate("sites.google.com/site/correojabril/", 265, 173, 193, 125)
GUICtrlCreateLabel("Ax^2+Bx+c=0", 175, 8, 1000 ,17)
$TA = GUICtrlCreateLabel("A", 8, 8, 36, 17)
$TB = GUICtrlCreateLabel("B", 8, 40, 36, 17)
$TC = GUICtrlCreateLabel("C", 8, 72, 36, 17)
$VA = GUICtrlCreateInput("", 64, 8, 73, 21)
$VB = GUICtrlCreateInput("", 64, 40, 73, 21)
$VC = GUICtrlCreateInput("", 64, 72, 73, 21)
$VX1 = GUICtrlCreateInput("", 40, 112, 49, 21)
$VX2 = GUICtrlCreateInput("", 40, 144, 49, 21)
$TX1 = GUICtrlCreateLabel("= X1", 120, 112, 36, 17)
$TX2 = GUICtrlCreateLabel("= X2", 120, 144, 36, 17)
$BC = GUICtrlCreateButton("Calcular", 184, 32, 73, 33, 0)
$BR = GUICtrlCreateButton("Reset", 184, 80, 73, 33, 0)
GUISetState()
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $BC
$Calculo = (GUICtrlRead($VB)^2)-(4*GUICtrlRead($VA)*GUICtrlRead($VC))
If GUICtrlRead($VA) = "" and GUICtrlRead($VB) = "" and GUICtrlRead($VC) = "" then MsgBox(4096, "ERROR", "RELLENA LOS CAMPOS : A, B y C")
If GUICtrlRead($VA) <> "" and GUICtrlRead($VB) <> "" and GUICtrlRead($VC) = "" then MsgBox(4096, "ERROR", "RELLENA EL CAMPO : C")
If GUICtrlRead($VA) <> "" and GUICtrlRead($VB) = "" and GUICtrlRead($VC) <> "" then MsgBox(4096, "ERROR", "RELLENA EL CAMPO : B")
If GUICtrlRead($VA) = "" and GUICtrlRead($VB) <> "" and GUICtrlRead($VC) <> "" then MsgBox(4096, "ERROR", "RELLENA EL CAMPO : A")
If GUICtrlRead($VA) <> "" and GUICtrlRead($VB) = "" and GUICtrlRead($VC) = "" then MsgBox(4096, "ERROR", "RELLENA LOS CAMPOS : B y C")
If GUICtrlRead($VA) = "" and GUICtrlRead($VB) <> "" and GUICtrlRead($VC) = "" then MsgBox(4096, "ERROR", "RELLENA LOS CAMPOS : A y C")
If GUICtrlRead($VA) = "" and GUICtrlRead($VB) = "" and GUICtrlRead($VC) <> "" then MsgBox(4096, "ERROR", "RELLENA LOS CAMPOS : A y B")
If $Calculo < 0 Then MsgBox(4096, "Sin Solucion", "La ecuacion no tiene solución", 10)
If GuiCtrlRead($Calculo) > 0 Then GUICtrlSetData($VX1, ((0-GUICtrlRead($VB))+sqrt($Calculo))/(2*GUICtrlRead($VA)))
If GuiCtrlRead($Calculo) > 0 Then GUICtrlSetData($VX2, ((0-GUICtrlRead($VB))-sqrt($Calculo))/(2*GUICtrlRead($VA)))
If GuiCtrlRead($Calculo) = 0 and GUICtrlRead($VA) <> "" and GUICtrlRead($VB) <> "" and GUICtrlRead($VC) <> "" Then GUICtrlSetData($VX1, ((0-GUICtrlRead($VB))/(2*GUICtrlRead($VA))))
If GuiCtrlRead($Calculo) = 0 and GUICtrlRead($VA) <> "" and GUICtrlRead($VB) <> "" and GUICtrlRead($VC) <> "" Then GUICtrlSetData($VX2, "1 Sol")
Case $msg = $BR
GUICtrlSetData($VA,"")
GUICtrlSetData($VB,"")
GUICtrlSetData($VC,"")
GUICtrlSetData($VX1,"")
GUICtrlSetData($VX2,"")
EndSelect
WEnd
EndFunc