Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/07/2009, 14:06
Avatar de abrahamvj
abrahamvj
 
Fecha de Ingreso: julio-2006
Ubicación: Lima, Peru
Mensajes: 708
Antigüedad: 17 años, 9 meses
Puntos: 18
Respuesta: Pasar Codigo a una function VBA

Pues en ninguna parte mandas el valor de la operacion hacia la funcion:

Function digitoVerficadorRUT(rut As Double) As String
Dim i As Integer
largo = Len(rut)
Suma = 0
For i = 1 To 8
If largo = 8 Then
rut = Right(rut, 8)
Suma = Suma + Val(Mid(rut, i, 1)) * Val(Mid("32765432", i, 1))
Else
rut = Right(rut, 7)
Suma = Suma + Val(Mid(rut, i, 1)) * Val(Mid("2765432", i, 1))
End If
Next i
dv = 11 - (Suma Mod 11)
If dv = 10 Then dv = "K"
If dv = 11 Then dv = 0
'txtDv = Dv
digitoVerficadorRUT = dv
End Function

Mira la ultima linea que agregue. OJO, no declaras variables y otras cositas mas que podrian mejorar tu codigo.-

Abraham