Dim rot as Variant 
Dim TableOut[12]


Sub outw (event)

Dim msgPREVENT1 as Variant
X = val(TextCtrl1.GetValue()) 
if ComboBox2.getValue() = "Galón" Then
X = X/0.2642008
End If
if ComboBox2.getValue() = "Pinta" Then
X = X/2.1141649
End If
if ComboBox2.getValue() = "Quart" Then
X = X/1.0570825
End If

TableOut[1] = grid.GetCellValue(20, 0) : TableOut[7] = val(grid.GetCellValue(20, 1))
TableOut[2] = grid.GetCellValue(21, 0) : TableOut[8] = val(grid.GetCellValue(21, 1))
TableOut[3] = grid.GetCellValue(22, 0) : TableOut[9] = val(grid.GetCellValue(22, 1))
TableOut[4] = grid.GetCellValue(23, 0) : TableOut[10] = val(grid.GetCellValue(23, 1))
TableOut[5] = grid.GetCellValue(24, 0) : TableOut[11] = val(grid.GetCellValue(24, 1)) 
TableOut[6] = grid.GetCellValue(25, 0) : TableOut[12] = val(grid.GetCellValue(25, 1))

PER = X/((100-TableOut[7])/100)/((100-TableOut[8])/100)/((100-TableOut[9])/100)/((100-TableOut[10])/100)/((100-TableOut[11])/100)/((100-TableOut[12])/100)	
		
		PPH = int((PER - X)*100)/100
		WW = val(grid.GetCellValue(0, 1)) 
        VDH = PER 
        VAH = ((VDH) / ((100 - WW) / 100))

        C = val(grid.GetCellValue(1, 1))
        M = val(grid.GetCellValue(5, 1))
        T = val(grid.GetCellValue(3, 1))
        A = val(grid.GetCellValue(7, 1))
        R = val(grid.GetCellValue(9, 1))
        msgPREVENT1 = X + PER + WW + C + M + T + A + R
		
		IF msgPREVENT1 = 0 then
         wxMessageBox("Porfavor, introduzca valores.")
		end if
		
		if msgPREVENT1 > 0 then
		if combobox1.getvalue() = "lb" then
		A = A/2.203
		C = C/2.203
		M = M/2.203
		T = T/2.203
		R = R/2.203
		End If
		if combobox1.getvalue() = "g" then
		A = A/1000
		C = C/1000
		M = M/1000
		T = T/1000
		R = R/1000
		End If
		if combobox1.getvalue() = "onza" then
		A = A/35.2734
		C = C/35.2734
		M = M/35.2734
		T = T/35.2734
		R = R/35.2734
		End If
	
		
		IbuAct = 1
		CCR = A + C + M + T + R
        REP = 4 
        VEM = int((CCR * REP)*100) /100 
		
		VEM1 = Int(VEM * 100) / 100
        VAH1 = Int(VAH * 100) / 100

        RC = val(grid.GetCellValue(2, 1))
        RM = val(grid.GetCellValue(6, 1))
        RT = val(grid.GetCellValue(4, 1))
        RA = val(grid.GetCellValue(8, 1))
        RR = val(grid.GetCellValue(10, 1))
		
If VDH = 0 Then
VDH = 1
End If
        P = (((C * (RC / 100)) + (M * (RM / 100)) + (T * (RT / 100)) + (A * (RA / 100)) + (R * (RR / 100))) * 100) / VDH
        VEM1 = Int(VEM * 100) / 100
        PAH = (((C * (RC / 100)) + (M * (RM / 100)) + (T * (RM / 100)) + (A * (RA / 100)) + (R * (RR / 100))) * 100) / VAH
        P1 = Int(P * 100) / 100
      
		PF = ((((C * (RC / 100)) * 0.64) + ((M * (RM / 100)) * 0.64) + ((T * (RM / 100)) * 0.64) + ((A * (RA / 100)) * 0.64) + ((R * (RR / 100)) * 0.99))*100)  / VDH
        PFIN = P - PF
        DI = (P * 4) + 1000 : DF = (PFIN * 4) + 1000 : DAH = (PAH * 4) + 1000
        VALP = Int(((DI - DF) * 0.13125) * 100) / 100
        		
ListControl.SetStringItem(0,1,P1) 
ListControl.SetStringItem(5,1,int(DI*100)/100)
ListControl.SetStringItem(6,1,int(DAH*100)/100)
ListControl.SetStringItem(7,1,VALP)
ListControl.SetStringItem(8,1, VAH1)
ListControl.SetStringItem(9,1, VEM)
ListControl.SetStringItem(10,1,PPH)
myMenu1.Enable(5,TRUE) 
				
		end if
End Sub

Sub close1 ( event )
myMenu1.Enable( 5, FALSE )
myChildFrame1.show( FALSE )
frameReport.show( FALSE )
frame1.show( FALSE )
Enablek1 = 0
End sub

Connect( Button2, wxEVT_COMMAND_BUTTON_CLICKED, "outw" )

