I have a form where I define code masks in a masked textbox, for example CA##### and assign it to a textbox that I am using as the code of relevant form. ( Current Account Code = CA0001).
How can I increment the value automatically?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna Rajput SinghRank #605 · 4K reputationPosted Feb 19, 2016, 1:57 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 19, 2016, 1:32 AM EST
public partial class Form1 : Form { static int billno=2000; string code; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { billno = billno + 1; textBox1.Text = billno.ToString(); }Vipan SharmaRank #1,589 · 999 reputationPosted Feb 19, 2016, 2:23 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 19, 2016, 3:08 AM EST
Matthias24 reputationPosted Feb 19, 2016, 6:38 AM EST
Vipan SharmaRank #1,589 · 999 reputationPosted Feb 19, 2016, 6:25 PM EST
Yucel Emir14 reputationPosted Feb 21, 2016, 2:02 AM EST
Matthias24 reputationPosted Feb 21, 2016, 5:27 AM EST
Riddhi ValechaRank #794 · 2.9K reputationPosted Feb 21, 2016, 7:09 AM EST
Yucel Emir14 reputationPosted Feb 22, 2016, 7:31 PM EST
Yucel Emir14 reputationPosted Feb 22, 2016, 7:32 PM EST
Yucel Emir14 reputationPosted Feb 22, 2016, 7:32 PM EST
Yucel Emir14 reputationPosted Feb 22, 2016, 7:33 PM EST
Yucel Emir14 reputationPosted Feb 22, 2016, 7:33 PM EST
Ranjit PowarRank #553 · 4.4K reputationPosted Feb 22, 2016, 7:41 PM EST
Ranjit PowarRank #553 · 4.4K reputationPosted Feb 21, 2016, 3:29 AM EST
string str= textBox1.Text;
string intPart= str.Substring (3,5);
int nextValue=Convert.ToInt32(intPart)+1;
textBox1.Text="CAR"+ nextValue.ToString("0000");
If it helps you select it as correct answer.