Documentos de Académico
Documentos de Profesional
Documentos de Cultura
1000
10000
100000
CODIGO C#
strComas = "";
if (strValor.Length == 0) return "";
strValor =
strValor.Replace(Application.CurrentCulture.NumberFormat.NumberGroupSeparator, "");
if
(strValor.Contains(Application.CurrentCulture.NumberFormat.NumberDecimalSeparator))
{
strAux = strValor.Substring(0,
strValor.LastIndexOf(Application.CurrentCulture.NumberFormat.NumberDecimalSeparator
));
strComas =
strValor.Substring(strValor.LastIndexOf(Application.CurrentCulture.NumberFormat.Num
berDecimalSeparator) + 1);
}
else {
strAux = strValor;
}
if (strAux.Substring(0, 1) ==
Application.CurrentCulture.NumberFormat.NegativeSign) {
bolMenos = true;
strAux = strAux.Substring(1);
}
strPuntos = strAux;
strAux = "";
while (strPuntos.Length > 3) {
strAux = Application.CurrentCulture.NumberFormat.NumberGroupSeparator +
strPuntos.Substring(strPuntos.Length - 3, 3) + strAux;
strPuntos = strPuntos.Substring(0, strPuntos.Length - 3);
}
if (intNumDecimales > 0) {
if
(strValor.Contains(Application.CurrentCulture.NumberFormat.PercentDecimalSeparator)
) {
strComas =
Application.CurrentCulture.NumberFormat.PercentDecimalSeparator +
strValor.Substring(strValor.LastIndexOf(Application.CurrentCulture.NumberFormat.Per
centDecimalSeparator) + 1);
if (strComas.Length > intNumDecimales) {
strComas = strComas.Substring(0, intNumDecimales + 1);
}
}
}
strAux = strPuntos + strAux + strComas;
return strAux;
}
CODIGO VB:
If strValor.Length = 0 Then
Return ""
End If
strValor =
strValor.Replace(Application.CurrentCulture.NumberFormat.NumberGroupSeparator, "")
If
strValor.Contains(Application.CurrentCulture.NumberFormat.NumberDecimalSeparator)
Then
strAux = strValor.Substring(0,
strValor.LastIndexOf(Application.CurrentCulture.NumberFormat.NumberDecimalSeparator
))
strComas =
strValor.Substring(strValor.LastIndexOf(Application.CurrentCulture.NumberFormat.Num
berDecimalSeparator) + 1)
Else
strAux = strValor
End If
If strAux.Substring(0, 1) =
Application.CurrentCulture.NumberFormat.NegativeSign Then
bolMenos = True
strAux = strAux.Substring(1)
End If
strPuntos = strAux
strAux = ""
While strPuntos.Length > 3
strAux = Application.CurrentCulture.NumberFormat.NumberGroupSeparator +
strPuntos.Substring(strPuntos.Length - 3, 3) + strAux
strPuntos = strPuntos.Substring(0, strPuntos.Length - 3)
End While
If intNumDecimales > 0 Then
If
strValor.Contains(Application.CurrentCulture.NumberFormat.PercentDecimalSeparator)
Then
strComas =
Application.CurrentCulture.NumberFormat.PercentDecimalSeparator +
strValor.Substring(strValor.LastIndexOf(Application.CurrentCulture.NumberFormat.Per
centDecimalSeparator) + 1)
If strComas.Length > intNumDecimales Then
strComas = strComas.Substring(0, intNumDecimales + 1)
End If
End If
End If
strAux = strPuntos + strAux + strComas
Return strAux
End Function
c#
VB
textBox1.KeyUp += TextBox1_KeyUp;
private void TextBox1_KeyUp(object sender, KeyEventArgs e)
{
textBox2.AppendText( $"KeyUp code: {e.KeyCode}, value: {e.KeyValue},
modifiers: {e.Modifiers}" + "\r\n");
}