Hola a todos, amigos del foro.
Tengo la necesidad de usar una funcion que esta hecha en C .
Se puede usar directamente? c贸mo ? o hay que pasarla a xBase?
En caso de que haya que pasarla, puede alguien darme una mano? no tengo idea de C.
Este es el codigo:
Se ve muy sencilla y hasta se entiende, pero ya sabemos que en programaci贸n una coma o punto hace la diferencia entre bien y mal.
Como siempre, agradezco de antemano la ayuda que puedan prestarme.
Gracias !!
Tengo la necesidad de usar una funcion que esta hecha en C .
Se puede usar directamente? c贸mo ? o hay que pasarla a xBase?
En caso de que haya que pasarla, puede alguien darme una mano? no tengo idea de C.
Este es el codigo:
public bool validarRif(string sRif)
聽 聽 聽 聽 {
聽 聽 聽 聽 聽 聽 bool bResultado = false;
聽 聽 聽 聽 聽 聽 int iFactor = 0;
聽 聽 聽 聽 聽 聽 sRif = sRif.Replace("-", "");
聽 聽 聽 聽 聽 聽 if (sRif.Length < 10)
聽 聽 聽 聽 聽 聽 聽 聽 sRif = sRif.ToUpper().Substring(0, 1) + sRif.Substring(1, sRif.Length - 1).PadLeft(9, '0');
聽 聽 聽 聽 聽 聽 聽string sPrimerCaracter = sRif.Substring(0, 1).ToUpper();
聽 聽 聽 聽 聽 聽 switch (sPrimerCaracter)
聽 聽 聽 聽 聽 聽 {
聽 聽 聽 聽 聽 聽 聽 聽 case "V": iFactor = 1; break;
聽 聽 聽 聽 聽 聽 聽 聽 case "E": iFactor = 2; break;
聽 聽 聽 聽 聽 聽 聽 聽 case "J": iFactor = 3; break;
聽 聽 聽 聽 聽 聽 聽 聽 case "P": iFactor = 4; break;
聽 聽 聽 聽 聽 聽 聽 聽 case "G": iFactor = 5; break;
聽 聽 聽 聽 聽 聽 }
聽 聽 聽 聽 聽 聽 if (iFactor > 0)
聽 聽 聽 聽 聽 聽 {
聽 聽 聽 聽 聽 聽 聽 聽 int suma = ((int.Parse(sRif.Substring(8, 1))) * 2)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ ((int.Parse(sRif.Substring(7, 1))) * 3)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ ((int.Parse(sRif.Substring(6, 1))) * 4)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ ((int.Parse(sRif.Substring(5, 1))) * 5)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ ((int.Parse(sRif.Substring(4, 1))) * 6)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ ((int.Parse(sRif.Substring(3, 1))) * 7)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ ((int.Parse(sRif.Substring(2, 1))) * 2)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ ((int.Parse(sRif.Substring(1, 1))) * 3)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽+ (iFactor * 4);
聽 聽 聽 聽 聽 聽 聽 聽 float dividendo = suma / 11;
聽 聽 聽 聽 聽 聽 聽 聽 int DividendoEntero = (int)dividendo;
聽 聽 聽 聽 聽 聽 聽 聽 int resto = 11 - (suma - DividendoEntero * 11);
聽 聽 聽 聽 聽 聽 聽 聽 if (resto >= 10 || resto < 1)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 resto = 0;
聽 聽 聽 聽 聽 聽 聽 聽 if (sRif.Substring(9, 1).Equals(resto.ToString()))
聽 聽 聽 聽 聽 聽 聽 聽 {
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 bResultado = true;
聽 聽 聽 聽 聽 聽 聽 聽 }
聽 聽 聽 聽 聽 聽 }
聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 return bResultado;
聽 聽 聽 聽 }Como siempre, agradezco de antemano la ayuda que puedan prestarme.
Gracias !!
"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."
Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin
Carora, Estado Lara, Venezuela.
Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin
Carora, Estado Lara, Venezuela.