Calculating multiple conversions through a combo box - c#

So, below is as far as I've gotten. It keeps telling me I am unable to use a mathematical operator on a decimal or double. Unfortunately, those are what I have to use. What I'm trying to do is convert measurements of lengths from imperial to metric. I've looked through many other questions referring to this and was able to figure out parts of the code and how to get it to let me do an "if" statement. But I just can't figure out the math part of it. Can anyone point me in the right direction?
public partial class Form1 : Form
{
string conversions;
decimal meter, feet, centimeter, inches, miles, kilometers;
public Form1()
{
InitializeComponent();
}
private void btnCalculate_Click(object sender, EventArgs e)
{
calculateConversions();
}
private void Form1_Load(object sender, EventArgs e)
{
cbConversion.SelectedText = "Miles to Kilometers";
string[] Conversion = new string[] { "Miles to Kilometers",
"Kilometers to Miles",
"Feet to Meters",
"Meters to Feet",
"Inches to Centimeters",
"Centermeters to Inches" };
{ }
for (int i = 0; i < Conversion.Length; i++)
{
cbConversion.Items.Add(Convert.ToString(Conversion[i]));
}
miles = 0m;
kilometers = 0m;
feet = 0m;
meter = 0m;
inches = 0m;
centimeter = 0m;
}
private void cbConversion_SelectedIndexChanged(object sender, EventArgs e)
{
conversions = Convert.ToString(cbConversion.SelectedItem);
IList<string> lstString = new List<string>();
lstString.Add("Miles:");
lstString.Add("Kilometers:");
lstString.Add("Feet:");
lstString.Add("Meters:");
lstString.Add("Inches:");
lstString.Add("Centimeters:");
label2.Text = lstString[cbConversion.SelectedIndex];
IList<string> lstStringTwo = new List<string>();
lstStringTwo.Add("Kilometers:");
lstStringTwo.Add("Miles:");
lstStringTwo.Add("Meters:");
lstStringTwo.Add("Feet:");
lstStringTwo.Add("Centimeters:");
lstStringTwo.Add("Inches:");
label3.Text = lstStringTwo[cbConversion.SelectedIndex];
}
private void calculateConversions()
{
decimal input = Convert.ToDecimal(txtInput.Text);
decimal output = Convert.ToDecimal(txtOutput.Text);
if (cbConversion.SelectedText == "Miles to Kilometers")
{
decimal miles = Convert.ToDecimal("");
}
I've even looked through my book and can't figure it out (it's a homework assignment)
The GUI I have. It's selected through the combobox and the entered text is calculated into the conversion. Everything works but the math

I added cbConversion.SelectedIndex = 0; in form1_load to select the first index of the combo box, then on calculateConversions() function in every condition i output in the textoutput.text.
Then the rest you can do else if and research for other formula for conversion.
And I used cbConversion.SelectedItem.ToString() so you can get item text from combobox to compare.
You can try this
string conversions;
decimal meter, feet, centimeter, inches, miles, kilometers;
private void btnCalculate_Click(object sender, EventArgs e)
{
calculateConversions();
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
cbConversion.SelectedText = "Miles to Kilometers";
string[] Conversion = new string[] { "Miles to Kilometers",
"Kilometers to Miles",
"Feet to Meters",
"Meters to Feet",
"Inches to Centimeters",
"Centermeters to Inches" };
{ }
for (int i = 0; i < Conversion.Length; i++)
{
cbConversion.Items.Add(Convert.ToString(Conversion[i]));
}
miles = 0m;
kilometers = 0m;
feet = 0m;
meter = 0m;
inches = 0m;
centimeter = 0m;
cbConversion.SelectedIndex = 0;
}
private void cbConversion_SelectedIndexChanged(object sender, EventArgs e)
{
conversions = Convert.ToString(cbConversion.SelectedItem);
IList<string> lstString = new List<string>();
lstString.Add("Miles:");
lstString.Add("Kilometers:");
lstString.Add("Feet:");
lstString.Add("Meters:");
lstString.Add("Inches:");
lstString.Add("Centimeters:");
label2.Text = lstString[cbConversion.SelectedIndex];
IList<string> lstStringTwo = new List<string>();
lstStringTwo.Add("Kilometers:");
lstStringTwo.Add("Miles:");
lstStringTwo.Add("Meters:");
lstStringTwo.Add("Feet:");
lstStringTwo.Add("Centimeters:");
lstStringTwo.Add("Inches:");
label3.Text = lstStringTwo[cbConversion.SelectedIndex];
}
private void calculateConversions()
{
decimal input = Convert.ToDecimal(txtInput.Text);
decimal mileToKM = Convert.ToDecimal(1.609344);
if (cbConversion.SelectedItem.ToString() == "Miles to Kilometers")
{
decimal miles = (input * mileToKM);
txtOutput.Text = miles.ToString();
}
}
OUTPUT

#justinmontalban this is the code I'm using now
private void Form1_Load(object sender, EventArgs e)
{
cbConversion.SelectedText = "Miles to Kilometers";
string[] Conversion = new string[] { "Miles to Kilometers",
"Kilometers to Miles",
"Feet to Meters",
"Meters to Feet",
"Inches to Centimeters",
"Centermeters to Inches" };
{ }
for (int i = 0; i < Conversion.Length; i++)
{
cbConversion.Items.Add(Convert.ToString(Conversion[i]));
}
miles = 0m;
kilometers = 0m;
feet = 0m;
meter = 0m;
inches = 0m;
centimeter = 0m;
cbConversion.SelectedIndex = 0;
}
private void cbConversion_SelectedIndexChanged(object sender, EventArgs e)
{
conversions = Convert.ToString(cbConversion.SelectedItem);
IList<string> lstString = new List<string>();
lstString.Add("Miles:");
lstString.Add("Kilometers:");
lstString.Add("Feet:");
lstString.Add("Meters:");
lstString.Add("Inches:");
lstString.Add("Centimeters:");
label2.Text = lstString[cbConversion.SelectedIndex];
IList<string> lstStringTwo = new List<string>();
lstStringTwo.Add("Kilometers:");
lstStringTwo.Add("Miles:");
lstStringTwo.Add("Meters:");
lstStringTwo.Add("Feet:");
lstStringTwo.Add("Centimeters:");
lstStringTwo.Add("Inches:");
label3.Text = lstStringTwo[cbConversion.SelectedIndex];
}
private void calculateConversions()
{
decimal input = Convert.ToDecimal(txtInput.Text);
decimal mileToKM = Convert.ToDecimal(1.6093);
decimal kMToMile = Convert.ToDecimal(0.6214);
decimal ftToM = Convert.ToDecimal(0.3048);
decimal mToFt = Convert.ToDecimal(3.2808);
decimal inToCm = Convert.ToDecimal(2.54);
decimal cmToIn = Convert.ToDecimal(0.3937);
if (cbConversion.SelectedText.ToString() == "Miles to Kilometers")
{
decimal miles = (input * mileToKM);
txtOutput.Text = miles.ToString();
}

Related

No syntax errors, but program does not produce any results

I have to create a program for class. My applications needs to have value returning methods for OilLubeCharges(), FlushCharges(), MiscCharges(), OtherCharges(), TaxCharges(), TotalCharges().
It needs to have void methods for ClearOilLube(), ClearFlushes(), ClearMisc(), ClearOther(), ClearFees().
Currently my code has no syntax errors, however when I compile it it does not calculate anything. The calculate, clear, and exit buttons also do not work. Any assistance as to why these issues are occurring would be appreciated. Below is my code.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void CalcButton_Click(object sender, EventArgs e)
{
OilLubeCharges();
FlushCharges();
MiscCharges();
OtherCharges();
TaxCharges();
TotalCharges();
}
private void ClearButton_Click(object sender, EventArgs e)
{
oilCheckBox.Checked = false;
lubeCheckBox.Checked = false;
radFlushBox.Checked = false;
tranFlushBox.Checked = false;
insCheckBox.Checked = false;
mufCheckBox.Checked = false;
tireCheckBox.Checked = false;
partsTextBox.Text = "";
laborTextBox.Text = "";
serLabTotalTextBox.Text = "";
partsTotalTextBox.Text = "";
taxPartsTextBox.Text = "";
totalFeesTextBox.Text = "";
}
private void ExitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private int OilLubeCharges()
{
int total = 0;
if (oilCheckBox.Checked)
{
total += 26;
serLabTotalTextBox.Text = total.ToString("c");
}
if (lubeCheckBox.Checked)
{
total += 18;
serLabTotalTextBox.Text = total.ToString("c");
return total;
}
else
{
return total;
}
}
private int FlushCharges()
{
int total = 0;
if (radFlushBox.Checked)
{
total += 30;
serLabTotalTextBox.Text = total.ToString("c");
}
if (tranFlushBox.Checked)
{
total += 80;
serLabTotalTextBox.Text = total.ToString("c");
return total;
}
else
{
return total;
}
}
private int MiscCharges()
{
int total = 0;
if (insCheckBox.Checked)
{
total += 15;
serLabTotalTextBox.Text = total.ToString("c");
}
if (mufCheckBox.Checked)
{
total += 100;
serLabTotalTextBox.Text = total.ToString("c");
}
if (tireCheckBox.Checked)
{
total += 20;
serLabTotalTextBox.Text = total.ToString("c");
return total;
}
else
{
return total;
}
}
private int OtherCharges()
{
int total = 0;
int parts = 0;
int labor = 0;
if (int.TryParse(partsTextBox.Text, out parts))
{
partsTextBox.Text = parts.ToString("c");
total = parts;
}
if (int.TryParse(laborTextBox.Text, out labor))
{
laborTextBox.Text = labor.ToString("c");
return total;
}
else
{
return total;
}
}
private decimal TaxCharges()
{
decimal parts = 0;
decimal partsTax;
partsTax = parts * .06m;
taxPartsTextBox.Text = partsTax.ToString("c");
return partsTax;
}
private decimal TotalCharges()
{
decimal total = 0;
total = OilLubeCharges() + FlushCharges() + MiscCharges() + TaxCharges() + OtherCharges();
totalFeesTextBox.Text = total.ToString("c");
return total;
}
}
As stated in the comments above, most likely your events are not hooked up to your buttons. You can do this several ways; typically it's done in the designer.
To know for sure if this is the cause, try this:
public Form1()
{
InitializeComponent();
CalcButton.Click += CalcButton_Click;
}
Note that this assumes your button is named "CalcButton". You can see whether that's true in the designer as well.
If that works, you need to do the same with the rest of your buttons either the same way or by selecting the method in the designer for the button.

Rewriting my code as a Method, using C# Visual Studio

I am currently having trouble understanding Methods and how they work in C#. I currently have code written for a car cost calculator program I created, I want to rearrange or break my code down using methods. I am unsure how or where to begin doing so as it pertains to my program. Here is my code, clarification would be helpful! Thank you!
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//constants for the Zone entered by user
const decimal ZoneCostN = 27;
const decimal ZoneCostS = 36;
const decimal ZoneCostE = 45;
const decimal ZoneCostW = 54;
private void CalcButton_Click(object sender, EventArgs e)
{
//set the variables
decimal PackWeight = 0;
decimal CostZone = 0;
decimal CostWeight = 0;
decimal ShippingTot = 0;
decimal Net = 0;
const decimal PerPound = 18;
//parses the entry into the textboxes
decimal.TryParse(WeightText.Text, out PackWeight); ;
//algorithm for variables
CostWeight = PackWeight * PerPound;
Zonelbl.Text = "";
CostZone = 0;
//if else statement to get the zone cost
{
if (NorthButton.Checked)
{
CostZone = ZoneCostN;
}
else if (SouthButton.Checked)
{
CostZone = ZoneCostS;
}
else if (EastButton.Checked)
{
CostZone = ZoneCostE;
}
else if (WestButton.Checked)
{
CostZone = ZoneCostW;
}
else
{
MessageBox.Show("Select a zone!");
}
}
//algorithm to get total and net
ShippingTot = CostZone + CostWeight;
Net = ShippingTot / CostWeight;
//if condition for CAPPED label
if (ShippingTot >= 100)
{
CAPPEDlbl.Visible = true;
}
else
{
CAPPEDlbl.Visible = false;
}
//output for all the data
Zonelbl.Text = CostZone.ToString("c");
Weightlbl.Text = CostWeight.ToString("c");
Totallbl.Text = ShippingTot.ToString("c");
Netlbl.Text = Net.ToString("c");
}
private void ClearButton_Click(object sender, EventArgs e)
{
//clears the form
Zonelbl.Text = "";
Weightlbl.Text = "";
Totallbl.Text = "";
Netlbl.Text = "";
WeightText.Text = "";
CAPPEDlbl.Visible = false;
WeightText.Focus();
}
}
Usually, we create methods when we need to reuse a code. In your case, you should see which part of your code will be reused in the future. If it is a simple form you may don't need to change anything but imagine you want to use your clear functionality somewhere else, create a method and call it everywhere you need
void clear()
{
Zonelbl.Text = "";
Weightlbl.Text = "";
Totallbl.Text = "";
Netlbl.Text = "";
WeightText.Text = "";
CAPPEDlbl.Visible = false;
WeightText.Focus();
}
private void ClearButton_Click(object sender, EventArgs e)
{
clear();
}
Now you can reuse clear() and in case you needed to change it you only need to change the method. It's the concept and you can apply it wherever you need.

C# Calculator using List Array error at some operations Windows Form Application

Hello I'm still new to programming and yes this is not the best code you will see... I tried making calculator on C# windows form for fun and I'm having trouble on the subtraction and division operations, but the addition and multiplication works perfectly fine for me. I decided to have a list array so that I would be able to input numbers as much as I want.
The error for the subtraction is when I input for example 5 - 2 the result will be -3
As for the division the error is that the result is always 1
Please tell me where did I go wrong and give a detailed explanation if possible so that I would understand more about programming. Thanks in advance!
namespace CalculatorTestForm1
{
public partial class Form1 : Form
{
public static List<int> Numlist = new List<int>();
public static string operation;
public Form1()
{
InitializeComponent();
}
private void Button_Click(object sender, EventArgs e)
{
Button Num = (Button)sender;
TXTBox.Text += Num.Text;
}
private void BPlus_Click(object sender, EventArgs e)
{
operation = "add";
int AddNum = Convert.ToInt32(this.TXTBox.Text);
Numlist.Add(AddNum);
TXTBox.Text = "";
}
private void BEquals_Click(object sender, EventArgs e)
{
int AddNum = Convert.ToInt32(this.TXTBox.Text);
Numlist.Add(AddNum);
int sum = 0;
int product = 1;
int quotient = 1;
int difference = 0;
if (operation == "add"){
foreach (int value in Numlist)
{
sum += value;
}
string Answer = sum.ToString();
TXTBox.Text = Answer;
}else if(operation == "minus"){
foreach (int value in Numlist)
{
difference = value - difference;
}
string Answer = difference.ToString();
TXTBox.Text = Answer;
}
else if (operation == "multiply")
{
foreach (int value in Numlist)
{
product *= value;
}
string Answer = product.ToString();
TXTBox.Text = Answer;
}
else if (operation == "divide")
{
foreach (int value in Numlist)
{
quotient = value / value;
}
string Answer = quotient.ToString();
TXTBox.Text = Answer;
}
Numlist.Clear();
}
private void BClear_Click(object sender, EventArgs e)
{
TXTBox.Text = "";
Numlist.Clear();
}
private void BMinus_Click(object sender, EventArgs e)
{
operation = "minus";
int AddNum = Convert.ToInt32(this.TXTBox.Text);
Numlist.Add(AddNum);
TXTBox.Text = "";
}
private void BDivide_Click(object sender, EventArgs e)
{
operation = "divide";
int AddNum = Convert.ToInt32(this.TXTBox.Text);
Numlist.Add(AddNum);
TXTBox.Text = "";
}
private void BMulti_Click(object sender, EventArgs e)
{
operation = "multiply";
int AddNum = Convert.ToInt32(this.TXTBox.Text);
Numlist.Add(AddNum);
TXTBox.Text = "";
}
}
}
For the division it's obvious:
quotient = value / value;
value/value will always be 1.
There must be quotient in that loop somewhere...
For the subtraction the problem is that because of the way you do it, the order of the numbers are reversed.
lets say 5 - 2:
foreach (int value in Numlist)
{
difference = value - difference;
}
NumList = {5,2}
1st iteration:
difference = value(5) - difference(0) = 5
2nd iteration:
difference = value(2) - difference(5) = -3
You should reverse the order of the loop: NumList.Reverse()
And for the division as well:
Division:
foreach (int value in Numlist.Reverse())
{
quotient = value / quotient;
}
Subtraction:
foreach (int value in Numlist)
{
difference = value - difference;
}

Multiplication in C# WPF

I'm trying to make a program that generates 2 random numbers, then, after the user inputs the multiplication of those numbers, it will tell the user in a MessageBox whether or not the user was right or wrong. Sort of like an educational simulator.
I'm having problems with the end part. What I'm saying is; If the answer is the same as number1 and number2 multiplied, then it says; "Rétt!" and if not; "Rangt..."
Any ideas?
private void bt_end_Click(object sender, RoutedEventArgs e)
{
int number1 = 0;
int number2 = 0;
int answer = 0;
tbnumber1.Text = number1.ToString();
tbnumber2.Text = number2.ToString();
if (svar == (number1 * number2))
{
MessageBox.Show("Rétt!");
}
else
{
MessageBox.Show("Rangt...");
}
}
}
}
The full code.
public MainWindow()
{
InitializeComponent();
}
int tala1 = 0;
int tala2 = 0;
int svar = 0;
private void btstart_Click(object sender, RoutedEventArgs e)
{
tbtala1.Text = "";
tbtala2.Text = "";
tbsvar.Text = "";
Random random = new Random();
tala1 = random.Next(1, 11);
tala2 = random.Next(1, 11);
tbtala1.Text = tala1.ToString();
tbtala2.Text = tala2.ToString();
}
private void btend_Click(object sender, RoutedEventArgs e)
{
tbtala1.Text = tala1.ToString();
tbtala2.Text = tala2.ToString();
tbsvar.Text = svar.ToString();
if (svar == (tala1 * tala2).ToString())
{
MessageBox.Show("Rétt!");
}
else
{
MessageBox.Show("Rangt... :(");
}
}
}
}
SOLVED. Thank you to everyone who did/tried to help.
Final Version:
Final Version:
public MainWindow()
{
InitializeComponent();
}
int tala1 = 0;
int tala2 = 0;
int svar = 0;
private void btstart_Click(object sender, RoutedEventArgs e)
{
tbtala1.Text = "";
tbtala2.Text = "";
tbsvar.Text = "";
Random random = new Random();
tala1 = random.Next(1, 11);
tala2 = random.Next(1, 11);
tbtala1.Text = tala1.ToString();
tbtala2.Text = tala2.ToString();
}
private void btend_Click(object sender, RoutedEventArgs e)
{
tala1 = Convert.ToInt32(tbtala1.Text);
tala2 = Convert.ToInt32(tbtala2.Text);
svar = Convert.ToInt32(tbsvar.Text);
if (svar == (tala1 * tala2))
{
MessageBox.Show("Rétt!");
}
else
{
MessageBox.Show("Rangt... :(");
}
To do this in a safe manner, you should not only Parse the text inputs to numbers, but you should also ensure that the text does in fact contain numbers first. If your numbers are supposed to be integers then you could use this:
private void bt_end_Click(object sender, RoutedEventArgs e)
{
int number1 = 0;
int number2 = 0;
if (int.TryParse(tbnumber1.Text, out number1) ||
int.TryParse(tbnumber12.Text, out number2)) MessageBox.Show("Rangt...");
MessageBox.Show(svar == number1 * number2 ? "Rétt!" : "Rangt...");
}
You're putting the numbers in the textbox values. you have to convert textbox values to numbers.
private void btend_Click(object sender, RoutedEventArgs e)
{
try{
tala1 = Convert.ToInt32(tbtala1.Text);
tala2 = Convert.ToInt32(tbtala2.Text);
svar = Convert.ToInt32(tbsvar.Text);
if (svar == (tala1 * tala2))
{
MessageBox.Show("Rétt!");
}
else
{
MessageBox.Show("Rangt... :(");
}
}catch{
MessageBox.Show("Invalid input");
}
}
You never define svar. You probably meant something like this, assuming svar was set earlier and is the correct product of the random multiplication:
private void bt_end_Click(object sender, RoutedEventArgs e)
{
int number1 = 0;
int number2 = 0;
number1 = int.Parse(tbnumber1.Text);
number2 = int.Parse(tbnumber2.Text);
if (svar == (number1 * number2))
{
MessageBox.Show("Rétt!");
}
else
{
MessageBox.Show("Rangt...");
}
}
1.I observed that you have not initialized variable 'svar' anywhere.
Initialise your svar variable with proper value.
2.Replace This :
if (svar == (number1 * number2).ToString())
With Following :
if (svar == (number1 * number2))

change decimal place in textbox using numericUpDown

Im using Visual Studio 2010, windows form (c#).
I need change decimals place of value in textbox using numericUpDown1.
example:
I tryed this code:
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
// tbxConvertito.Text = (decimal.Parse(tbxConvertito.Text) * 10m).ToString();
if (numericUpDown1.Value == 0)
{
int decimalPlace = 0;
// Decimal xDecimal = decimal.Parse(tbxConvertito.text);
decimal xDecimal = decimal.Parse(tbxConvertito.Text);
tbxConvertito.Text = (Math.Round(xDecimal, decimalPlace)).ToString();
}
if (numericUpDown1.Value == 1)
{
int decimalPlace = 1;
// Decimal xDecimal = decimal.Parse(tbxConvertito.text);
decimal xDecimal = decimal.Parse(tbxConvertito.Text);
tbxConvertito.Text = (Math.Round(xDecimal, decimalPlace)).ToString();
}
}
but not work. How can I solve this, please?
You should create field with decimal value, to keep original value.
If you do that:
int decimalPlace = 1;
decimal xDecimal = decimal.Parse(tbxConvertito.Text);
tbxConvertito.Text = (Math.Round(xDecimal, decimalPlace)).ToString();
You lose original value of your decimal variable.
Try this:
public partial class Form1 : Form
{
public decimal myDecimal = 3755.25012345M;
public Form1()
{
InitializeComponent();
tbxConvertito.Text = myDecimal.ToString();
numericUpDown1_ValueChanged(this, EventArgs.Empty);
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
int decimalPlace = (int)numericUpDown1.Value;
tbxConvertito.Text = Decimal.Round(myDecimal, decimalPlace).ToString();
}
}
Solution without use Round method:
public partial class Form1 : Form
{
public decimal myDecimal = 3755.25012345M;
public Form1()
{
InitializeComponent();
tbxConvertito.Text = myDecimal.ToString();
numericUpDown1_ValueChanged(this, EventArgs.Empty);
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
int decimalPlace = (int)numericUpDown1.Value;
string[] numbers = myDecimal.ToString().Split(new char[] { '.', ',' });
string tmp = string.Empty;
if (decimalPlace <= numbers[1].Length)
{
tmp = "," + numbers[1].Substring(0, decimalPlace);
if (tmp.EndsWith(","))
tmp = string.Empty;
}
else
tmp = "," + numbers[1];
tbxConvertito.Text = numbers[0] + tmp;
}
}
You can achieve this using String operations. Try this one
decimal xDecimal = decimal.Parse(tbxConvertito.Text);
string str = xDecimal.ToString();
if (!str.Contains(","))
decimalPlace--;
tbxConvertito.Text = str.Replace(",", "").Insert((str.Length-1) - decimalPlace,",");
And use it like this in your code
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
// tbxConvertito.Text = (decimal.Parse(tbxConvertito.Text) * 10m).ToString();
if (numericUpDown1.Value == 0)
{
int decimalPlace = 0;
// Decimal xDecimal = decimal.Parse(tbxConvertito.text);
decimal xDecimal = decimal.Parse(tbxConvertito.Text);
string str = xDecimal.ToString();
if (!str.Contains(","))
decimalPlace--;
tbxConvertito.Text = str.Replace(",", "").Insert((str.Length-1) - decimalPlace,",");
}
if (numericUpDown1.Value == 1)
{
int decimalPlace = 1;
// Decimal xDecimal = decimal.Parse(tbxConvertito.text);
decimal xDecimal = decimal.Parse(tbxConvertito.Text);
string str = xDecimal.ToString();
if (!str.Contains(","))
decimalPlace--;
tbxConvertito.Text = str.Replace(",", "").Insert((str.Length-1) - decimalPlace,",");
}
}

Categories

Resources