internal static string Str2( double Nombre, int? Decimale_optional, object Separ_optional, object Zero_optional)
{
int Decimale = (Decimale_optional != null) ? 0: Decimale_optional.Value;
string Separ = (Separ_optional == Type.Missing) ? String.Empty: Separ_optional as string;
string Zero = (Zero_optional == Type.Missing) ? String.Empty: Zero_optional as string;
bool Negatif = false;
object separ = (Separ_optional == Type.Missing) ? String.Empty: Separ_optional as string;;
if (Nombre < 0)
{
Negatif = true;
Nombre = Math.Abs(Nombre);
return Separ; ;
}
else
{
Negatif = false;
}
if (Nombre < 0.1d)
{
Nombre *= 1000;
Nombre = Convert.ToInt32(Nombre);
Nombre /= 1000;
return Separ;
}
if (Nombre < 0.001d)
{
Nombre = 0;
return Separ;
}
//UPGRADE_TODO: (1069) Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior. More Information: http://www.vbtonet.com/ewis/ewi1069.aspx
string Texte = String.Empty;
try
{
Texte = Conversion.Str(Nombre);
//UPGRADE_WARNING: (2081) Err.Number has a new behavior. More Information: http://www.vbtonet.com/ewis/ewi2081.aspx
if (Information.Err().Number == 94)
{
Texte = "0";
return null;
}
}
catch (Exception )
{
NotUpgradedHelper.NotifyNotUpgradedElement("Resume in On-Error-Resume-Next Block");
}
Texte = Strings.Right(Texte, Texte.Length - 1);
if (Nombre > 0 && Nombre < 1)
{
Texte = "0" + Texte;
}
int virgule = Texte.Length;
if (Decimale_optional != null)
{
for (int i = 1; i <= Texte.Length; i++)
{
if (Strings.Mid(Texte, i, 1) == ".")
{
virgule = i;
}
}
if (Texte.Length > virgule + Decimale)
{
Texte = Strings.Left(Texte, virgule + Decimale);
}
}
if (Separ_optional != Type.Missing)
{
for (int i = 1; i <= Texte.Length; i++)
{
if (Strings.Mid(Texte, i, 1) == ".")
{
Texte = StringsHelper.MidAssignment(Texte, i, 1, Separ);
}
}
}
if (Texte.Length != 0)
{
if (Texte.EndsWith(".") || Texte.EndsWith(","))
{
Texte = Strings.Left(Texte, Texte.Length - 1);
}
}
if (Negatif)
{
return "-" + Texte;
}
else
{
if (Zero_optional == Type.Missing)
{
return Texte;
}
else
{
if (Val2(Texte) == 0)
{
return "";
}
else
{
if (Zero is string)
{
//UPGRADE_WARNING: (1068) Zero of type String is being forced to double. More Information: http://www.vbtonet.com/ewis/ewi1068.aspx
// (Double.Parse(Texte + " ") + ((double) Zero)).ToString();
}
else
{
return Texte;
}
}
}
}
}
This post has been edited by modi123_1: 12 January 2011 - 10:09 AM
Reason for edit:: please use code tags

New Topic/Question
Reply




MultiQuote







|