Basic textbox textbox
Example
Basic 2720 2193(i want arrive this(2193) amount when i type 2720)
in the first textbox i type the amount 2720
in the second textbox i want (2720/31)25 = 2193
how to do?please send the code using csharp.
Loading
Kunal VaishyaPosted Jul 9, 2012, 7:08 AM
decimal AmountA, AmountB;
AmountA = Convert.ToDecimal(textBox1.Text);
AmountB = (AmountA / 31) * 25;
textBox2.Text = System.Math.Floor(AmountB).ToString();
in Text change event of Textbox1
VulpesPosted Jul 9, 2012, 6:59 AM
If you want to wait until the whole number is entered and focus is moved to a different control, then you can handle the Leave event instead:
Satyapriya NayakPosted Jul 9, 2012, 6:52 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace test
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
decimal a, b;
a = Convert.ToDecimal(textBox1.Text);
b = (a / 31) * 25;
textBox2.Text = b.ToString();
textBox2.Text = textBox2.Text.Substring(0, 4);
}
}
}
Thanks