<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Validar un NIT(Guatemala) en C#</title>
	<atom:link href="http://geoavila.com/validar-un-nitguatemala-en-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://geoavila.com/validar-un-nitguatemala-en-c/</link>
	<description>Desarrollo.. de software.</description>
	<lastBuildDate>Tue, 15 May 2012 22:11:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: GeoAvila</title>
		<link>http://geoavila.com/validar-un-nitguatemala-en-c/comment-page-1/#comment-9189</link>
		<dc:creator>GeoAvila</dc:creator>
		<pubDate>Wed, 21 Sep 2011 17:22:18 +0000</pubDate>
		<guid isPermaLink="false">http://geoavila.com/?p=232#comment-9189</guid>
		<description>Gracias por el aporte Saludos</description>
		<content:encoded><![CDATA[<p>Gracias por el aporte Saludos</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: moe</title>
		<link>http://geoavila.com/validar-un-nitguatemala-en-c/comment-page-1/#comment-9188</link>
		<dc:creator>moe</dc:creator>
		<pubDate>Wed, 21 Sep 2011 17:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://geoavila.com/?p=232#comment-9188</guid>
		<description>Mismo Código convertido a Visual Basic.

&#039;&#039;&#039; 
            &#039;&#039;&#039; Función para verificar el Nit Ingresado.
            &#039;&#039;&#039; 
            &#039;&#039;&#039; Nit a Verificar
            &#039;&#039;&#039; True o False
            &#039;&#039;&#039; Verifica si el nit ingresado tiene forma correcta.
            Public Function Valida_Nit_303(ByVal NIT As String) As Boolean
                Dim POS As Integer
                Dim Correlativo As String
                Dim DigitoVerificador As String
                Dim Factor As Integer
                Dim Suma As Integer = 0
                Dim Valor As Integer = 0
                Dim X As Integer
                Dim xMOD11 As Double = 0
                Dim S As String = &quot;&quot;
                Valida_Nit_303 = False
                Try
                    POS = NIT.IndexOf(&quot;-&quot;)
                    If POS = 0 Then Exit Function
                    Correlativo = NIT.Substring(0, POS)
                    DigitoVerificador = NIT.Substring(POS + 1)
                    Factor = Correlativo.Length + 1
                    For X = 0 To (NIT.IndexOf(&quot;-&quot;) - 1)
                        Valor = Convert.ToInt32(NIT.Substring(X, 1))
                        Suma += (Valor * Factor)
                        Factor -= 1
                    Next
                    xMOD11 = (11 - (Suma Mod 11)) Mod 11
                    S = Convert.ToString(xMOD11)
                    If (xMOD11 = 10 And DigitoVerificador = &quot;K&quot;) Or (S = DigitoVerificador) Then
                        Valida_Nit_303 = True
                    End If
                Catch ex As Exception
                    MsgBox(ex.toString)
                End Try
            End Function</description>
		<content:encoded><![CDATA[<p>Mismo Código convertido a Visual Basic.</p>
<p>&#8221;&#8217;<br />
            &#8221;&#8217; Función para verificar el Nit Ingresado.<br />
            &#8221;&#8217;<br />
            &#8221;&#8217; Nit a Verificar<br />
            &#8221;&#8217; True o False<br />
            &#8221;&#8217; Verifica si el nit ingresado tiene forma correcta.<br />
            Public Function Valida_Nit_303(ByVal NIT As String) As Boolean<br />
                Dim POS As Integer<br />
                Dim Correlativo As String<br />
                Dim DigitoVerificador As String<br />
                Dim Factor As Integer<br />
                Dim Suma As Integer = 0<br />
                Dim Valor As Integer = 0<br />
                Dim X As Integer<br />
                Dim xMOD11 As Double = 0<br />
                Dim S As String = &#8220;&#8221;<br />
                Valida_Nit_303 = False<br />
                Try<br />
                    POS = NIT.IndexOf(&#8220;-&#8221;)<br />
                    If POS = 0 Then Exit Function<br />
                    Correlativo = NIT.Substring(0, POS)<br />
                    DigitoVerificador = NIT.Substring(POS + 1)<br />
                    Factor = Correlativo.Length + 1<br />
                    For X = 0 To (NIT.IndexOf(&#8220;-&#8221;) &#8211; 1)<br />
                        Valor = Convert.ToInt32(NIT.Substring(X, 1))<br />
                        Suma += (Valor * Factor)<br />
                        Factor -= 1<br />
                    Next<br />
                    xMOD11 = (11 &#8211; (Suma Mod 11)) Mod 11<br />
                    S = Convert.ToString(xMOD11)<br />
                    If (xMOD11 = 10 And DigitoVerificador = &#8220;K&#8221;) Or (S = DigitoVerificador) Then<br />
                        Valida_Nit_303 = True<br />
                    End If<br />
                Catch ex As Exception<br />
                    MsgBox(ex.toString)<br />
                End Try<br />
            End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: APO</title>
		<link>http://geoavila.com/validar-un-nitguatemala-en-c/comment-page-1/#comment-6960</link>
		<dc:creator>APO</dc:creator>
		<pubDate>Mon, 02 Aug 2010 23:43:21 +0000</pubDate>
		<guid isPermaLink="false">http://geoavila.com/?p=232#comment-6960</guid>
		<description>hola aca les dejo en C# el algoritmo del NIT para Guatemala, me fue de gran utilidad, ya que me salvo saludos.

namespace NIT
{
    public partial class FrmNIT : Form
    {
        public FrmNIT()
        {
            InitializeComponent();
        }

        private void btnValidar_Click(object sender, EventArgs e)
        {
            if (ValidarNIT(txtNit.Text.ToUpper()))
            {
                MessageBox.Show(&quot;NIT VALIDO: &quot;   txtNit.Text);
            }
            else
            {
                MessageBox.Show(&quot;NIT NO VALIDO: &quot;   txtNit.Text);
            }
        }


        public bool ValidarNIT(string Nit)
        {
            try
            {

                if (Nit == &quot;&quot;) return true;
                if (Nit == &quot;CF&quot; &#124;&#124; Nit == &quot;C/F&quot;) return true;
                int pos = Nit.IndexOf(&quot;-&quot;);

                if (pos &lt; 0)
                {
                    string correlativo = Nit.Substring(0, Nit.Length - 1);
                    correlativo = correlativo   &quot;-&quot;;

                    int pos2 = correlativo.Length - 2;
                    string digito = Nit.Substring(pos2   1);
                    Nit = correlativo   digito;
                    pos = Nit.IndexOf(&quot;-&quot;);
                }

                string Correlativo = Nit.Substring(0, pos);
                string DigitoVerificador = Nit.Substring(pos   1);
                int Factor = Correlativo.Length   1;
                int Suma = 0;
                int Valor = 0;

                for (int x = 0; x &lt;= Nit.IndexOf(&quot;-&quot;) - 1; x  )
                {
                    Valor = Convert.ToInt32(Nit.Substring(x, 1));
                    Suma = Suma   (Valor * Factor);
                    Factor = Factor - 1;
                }

                double xMOd11 = 0;
                xMOd11 = (11 - (Suma % 11)) % 11;
                MessageBox.Show(&quot;Suma: &quot;   Suma);
                MessageBox.Show(&quot;Mod: &quot;   xMOd11);

                string s = Convert.ToString(xMOd11);
                if ((xMOd11 == 10 &amp; DigitoVerificador == &quot;K&quot;) &#124; (s == DigitoVerificador))
                {
                    return true;
                }
                return false;
            }
            catch (Exception) 
            {
                return false;
            }
            
        }



    }
}</description>
		<content:encoded><![CDATA[<p>hola aca les dejo en C# el algoritmo del NIT para Guatemala, me fue de gran utilidad, ya que me salvo saludos.</p>
<p>namespace NIT<br />
{<br />
    public partial class FrmNIT : Form<br />
    {<br />
        public FrmNIT()<br />
        {<br />
            InitializeComponent();<br />
        }</p>
<p>        private void btnValidar_Click(object sender, EventArgs e)<br />
        {<br />
            if (ValidarNIT(txtNit.Text.ToUpper()))<br />
            {<br />
                MessageBox.Show(&#8220;NIT VALIDO: &#8221;   txtNit.Text);<br />
            }<br />
            else<br />
            {<br />
                MessageBox.Show(&#8220;NIT NO VALIDO: &#8221;   txtNit.Text);<br />
            }<br />
        }</p>
<p>        public bool ValidarNIT(string Nit)<br />
        {<br />
            try<br />
            {</p>
<p>                if (Nit == &#8220;&#8221;) return true;<br />
                if (Nit == &#8220;CF&#8221; || Nit == &#8220;C/F&#8221;) return true;<br />
                int pos = Nit.IndexOf(&#8220;-&#8221;);</p>
<p>                if (pos &lt; 0)<br />
                {<br />
                    string correlativo = Nit.Substring(0, Nit.Length &#8211; 1);<br />
                    correlativo = correlativo   &quot;-&quot;;</p>
<p>                    int pos2 = correlativo.Length &#8211; 2;<br />
                    string digito = Nit.Substring(pos2   1);<br />
                    Nit = correlativo   digito;<br />
                    pos = Nit.IndexOf(&quot;-&quot;);<br />
                }</p>
<p>                string Correlativo = Nit.Substring(0, pos);<br />
                string DigitoVerificador = Nit.Substring(pos   1);<br />
                int Factor = Correlativo.Length   1;<br />
                int Suma = 0;<br />
                int Valor = 0;</p>
<p>                for (int x = 0; x &lt;= Nit.IndexOf(&quot;-&quot;) &#8211; 1; x  )<br />
                {<br />
                    Valor = Convert.ToInt32(Nit.Substring(x, 1));<br />
                    Suma = Suma   (Valor * Factor);<br />
                    Factor = Factor &#8211; 1;<br />
                }</p>
<p>                double xMOd11 = 0;<br />
                xMOd11 = (11 &#8211; (Suma % 11)) % 11;<br />
                MessageBox.Show(&quot;Suma: &quot;   Suma);<br />
                MessageBox.Show(&quot;Mod: &quot;   xMOd11);</p>
<p>                string s = Convert.ToString(xMOd11);<br />
                if ((xMOd11 == 10 &amp; DigitoVerificador == &quot;K&quot;) | (s == DigitoVerificador))<br />
                {<br />
                    return true;<br />
                }<br />
                return false;<br />
            }<br />
            catch (Exception)<br />
            {<br />
                return false;<br />
            }</p>
<p>        }</p>
<p>    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: APO</title>
		<link>http://geoavila.com/validar-un-nitguatemala-en-c/comment-page-1/#comment-6929</link>
		<dc:creator>APO</dc:creator>
		<pubDate>Thu, 22 Jul 2010 18:42:40 +0000</pubDate>
		<guid isPermaLink="false">http://geoavila.com/?p=232#comment-6929</guid>
		<description>Gracias por el aporte, ya lo prove en un proyecto y si me validó el NIT, gracias</description>
		<content:encoded><![CDATA[<p>Gracias por el aporte, ya lo prove en un proyecto y si me validó el NIT, gracias</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo Miranda</title>
		<link>http://geoavila.com/validar-un-nitguatemala-en-c/comment-page-1/#comment-6572</link>
		<dc:creator>Pablo Miranda</dc:creator>
		<pubDate>Fri, 18 Dec 2009 21:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://geoavila.com/?p=232#comment-6572</guid>
		<description>mmm al principio creí que solo verificaban el patrón, pero veo que el ultimo numero si tiene su razón de ser.</description>
		<content:encoded><![CDATA[<p>mmm al principio creí que solo verificaban el patrón, pero veo que el ultimo numero si tiene su razón de ser.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo Miranda</title>
		<link>http://geoavila.com/validar-un-nitguatemala-en-c/comment-page-1/#comment-6571</link>
		<dc:creator>Pablo Miranda</dc:creator>
		<pubDate>Fri, 18 Dec 2009 20:35:40 +0000</pubDate>
		<guid isPermaLink="false">http://geoavila.com/?p=232#comment-6571</guid>
		<description>y no hubiera sido mejor un REGEX? se me ocurre algo como ^([0-9]{5,})-(k&#124;[0-9]{1})$</description>
		<content:encoded><![CDATA[<p>y no hubiera sido mejor un REGEX? se me ocurre algo como ^([0-9]{5,})-(k|[0-9]{1})$</p>
]]></content:encoded>
	</item>
</channel>
</rss>

