4 Replies - 999 Views - Last Post: 02 September 2009 - 05:43 AM Rate Topic: -----

#1 hamidkhl  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-November 08

ERROR: input string is not in a correct format

Posted 01 September 2009 - 04:35 PM

hello
I created a form for inouting some strings by textboxes during the debug i have no error but when create a setp for it and instal it I can not save any strings and this error shows:
Unhandeled exception has occurred in your application....
Input string was not in a correct format
please help me
best regards
Is This A Good Question/Topic? 0
  • +

Replies To: ERROR: input string is not in a correct format

#2 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,222
  • Joined: 23-August 08

Re: ERROR: input string is not in a correct format

Posted 01 September 2009 - 04:36 PM

Need code, dude.
Was This Post Helpful? 0
  • +
  • -

#3 hamidkhl  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-November 08

Re: ERROR: input string is not in a correct format

Posted 01 September 2009 - 04:44 PM

this is my code but it have not any error after inastalation I have that problem :blink:


 private void btnRegister_Click(object sender, EventArgs e)
		{
			string newstr=RtxtMeaning.Text;
			if (!File.Exists(Application.StartupPath + "\\FlashMakerSecure.txt"))
			{
				File.Create(Application.StartupPath + "\\FlashMakerSecure.txt");
			}
			temp = File.ReadAllText(Application.StartupPath + "\\FlashMakerSecure.txt");
			labelcounter.Text = temp;
			int a=Convert.ToInt32(temp);
			if (a > 6)
			{
				a = a - 6;
				labelcounter.Text = a.ToString();
			}


			counter = Convert.ToInt32(temp);
			fileaddress = Application.StartupPath + "\\table.docx";

			object readonl = false;
			try
			{
				doc = wordapp.Documents.Open(ref filename, ref objmiss, ref readonl,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss, ref objmiss,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss);


				BtnClose.Enabled = true;
			}
			catch 
			{
				MessageBox.Show("Application will close because word file is closed, open application again if you want","ERROR");
				this.Close();
			}

			
			if (txtword.Text == "" || RtxtMeaning.Text == "")
				MessageBox.Show("Word or/and Meaning segment can not be empty,please type a word");
			else
			{
				RtxtMeaning.Text = newstr.Replace(txtword.Text, "......");
				if (counter == 1 || counter == 2 || counter == 13 || counter == 14 || counter == 25
					|| counter == 26 || counter == 37 || counter == 38 || counter == 49 || counter == 50
					|| counter == 61 || counter == 62 || counter == 73 || counter == 74 || counter == 85
					|| counter == 86 || counter == 97 || counter == 98 || counter == 109 || counter == 110)
				{
					counter2 = counter + 10;
				}
				else if (counter == 3 || counter == 4 || counter == 15 || counter == 16 || counter == 27
				   || counter == 28 || counter == 112 || counter == 39 || counter == 40 || counter == 51
				   || counter == 52 || counter == 63 || counter == 64 || counter == 75 || counter == 76
				   || counter == 87 || counter == 88 || counter == 99 || counter == 100 || counter == 111)
				{
					counter2 = counter + 6;
				}
				else if (counter == 5 || counter == 6 || counter == 17 || counter == 18 || counter == 29
				   || counter == 30 || counter == 41 || counter == 42 || counter == 53 || counter == 54
				   || counter == 65 || counter == 66 || counter == 77 || counter == 78 || counter == 89
				   || counter == 90 || counter == 101 || counter == 102 || counter == 113 || counter == 114)
				{
					counter2 = counter + 2;
				}
				if (flag3)
				{
					this.findandreplace(wordapp, counter, txtword.Text + "  " + txtpr.Text);
					this.findandreplace(wordapp, counter2, RtxtMeaning.Text);
					doc.Activate();
					wordapp.Visible = true;
					txtword.Text = "";
					RtxtMeaning.Text = "";
					txtpr.Text = "";
					txtword.Focus();
				}

				counter = counter + 1;
				if (counter == 7)
					counter = 13;
				if (counter == 19)
					counter = 25;
				if (counter == 19 + 12)
					counter = 25 + 12;
				if (counter == 19 + 12 + 12)
					counter = 25 + 12 + 12;
				if (counter == 19 + 12 + 12 + 12)
					counter = 25 + 12 + 12 + 12;
				if (counter == 19 + 12 + 12 + 12 + 12)
					counter = 25 + 12 + 12 + 12 + 12;
				if (counter == 19 + 12 + 12 + 12 + 12 + 12)
					counter = 25 + 12 + 12 + 12 + 12 + 12;

				strcount = counter.ToString();
				labelcounter.Text = strcount;
				File.WriteAllText(Application.StartupPath + "\\FlashMakerSecure.txt", strcount);
			}
			if (counter> 60)
				MessageBox.Show("Your sheets are full, you should save or print them","Time to print");
		}

		private void Form1_FormClosing(object sender, FormClosingEventArgs e)
		{
			wordapp = null;
			doc = null;
		}

		private void BtnClose_Click(object sender, EventArgs e)
		{
			button1.Enabled = true;
			object save=true;
			doc.Close(ref save,ref objmiss,ref objmiss);
			counter = 1;
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (textBox1.Text == "")
				MessageBox.Show("INSERT FILE NAME");
			else
			{
				textBox1.Visible = false;
				label9.Visible = false;
				File.Move(Application.StartupPath + "\\table.docx", "c:\\FlashCartMaker" + textBox1.Text + ".docx");
				File.Copy(Application.StartupPath + "\\table2.docx", Application.StartupPath + "\\table.docx");
				File.Delete(Application.StartupPath + "FlashMakerSecure.txt");
				File.WriteAllText(Application.StartupPath + "\\FlashMakerSecure.txt", "1");
			}

		}


Was This Post Helpful? 0
  • +
  • -

#4 hamidkhl  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-November 08

Re: ERROR: input string is not in a correct format

Posted 01 September 2009 - 04:48 PM

this is my code but it have not any error, after inastalation I have that problem :blink:
private void btnRegister_Click(object sender, EventArgs e)
		{
			string newstr=RtxtMeaning.Text;
			if (!File.Exists(Application.StartupPath + "\\FlashMakerSecure.txt"))
			{
				File.Create(Application.StartupPath + "\\FlashMakerSecure.txt");
			}
			temp = File.ReadAllText(Application.StartupPath + "\\FlashMakerSecure.txt");
			labelcounter.Text = temp;
			int a=Convert.ToInt32(temp);
			if (a > 6)
			{
				a = a - 6;
				labelcounter.Text = a.ToString();
			}


			counter = Convert.ToInt32(temp);
			fileaddress = Application.StartupPath + "\\table.docx";

			object readonl = false;
			try
			{
				doc = wordapp.Documents.Open(ref filename, ref objmiss, ref readonl,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss, ref objmiss,
											ref objmiss, ref objmiss,
											ref objmiss, ref objmiss);


				BtnClose.Enabled = true;
			}
			catch 
			{
				MessageBox.Show("Application will close because word file is closed, open application again if you want","ERROR");
				this.Close();
			}

			
			if (txtword.Text == "" || RtxtMeaning.Text == "")
				MessageBox.Show("Word or/and Meaning segment can not be empty,please type a word");
			else
			{
				RtxtMeaning.Text = newstr.Replace(txtword.Text, "......");
				if (counter == 1 || counter == 2 || counter == 13 || counter == 14 || counter == 25
					|| counter == 26 || counter == 37 || counter == 38 || counter == 49 || counter == 50
					|| counter == 61 || counter == 62 || counter == 73 || counter == 74 || counter == 85
					|| counter == 86 || counter == 97 || counter == 98 || counter == 109 || counter == 110)
				{
					counter2 = counter + 10;
				}
				else if (counter == 3 || counter == 4 || counter == 15 || counter == 16 || counter == 27
				   || counter == 28 || counter == 112 || counter == 39 || counter == 40 || counter == 51
				   || counter == 52 || counter == 63 || counter == 64 || counter == 75 || counter == 76
				   || counter == 87 || counter == 88 || counter == 99 || counter == 100 || counter == 111)
				{
					counter2 = counter + 6;
				}
				else if (counter == 5 || counter == 6 || counter == 17 || counter == 18 || counter == 29
				   || counter == 30 || counter == 41 || counter == 42 || counter == 53 || counter == 54
				   || counter == 65 || counter == 66 || counter == 77 || counter == 78 || counter == 89
				   || counter == 90 || counter == 101 || counter == 102 || counter == 113 || counter == 114)
				{
					counter2 = counter + 2;
				}
				if (flag3)
				{
					this.findandreplace(wordapp, counter, txtword.Text + "  " + txtpr.Text);
					this.findandreplace(wordapp, counter2, RtxtMeaning.Text);
					doc.Activate();
					wordapp.Visible = true;
					txtword.Text = "";
					RtxtMeaning.Text = "";
					txtpr.Text = "";
					txtword.Focus();
				}

				counter = counter + 1;
				if (counter == 7)
					counter = 13;
				if (counter == 19)
					counter = 25;
				if (counter == 19 + 12)
					counter = 25 + 12;
				if (counter == 19 + 12 + 12)
					counter = 25 + 12 + 12;
				if (counter == 19 + 12 + 12 + 12)
					counter = 25 + 12 + 12 + 12;
				if (counter == 19 + 12 + 12 + 12 + 12)
					counter = 25 + 12 + 12 + 12 + 12;
				if (counter == 19 + 12 + 12 + 12 + 12 + 12)
					counter = 25 + 12 + 12 + 12 + 12 + 12;

				strcount = counter.ToString();
				labelcounter.Text = strcount;
				File.WriteAllText(Application.StartupPath + "\\FlashMakerSecure.txt", strcount);
			}
			if (counter> 60)
				MessageBox.Show("Your sheets are full, you should save or print them","Time to print");
		}

		private void Form1_FormClosing(object sender, FormClosingEventArgs e)
		{
			wordapp = null;
			doc = null;
		}

		private void BtnClose_Click(object sender, EventArgs e)
		{
			button1.Enabled = true;
			object save=true;
			doc.Close(ref save,ref objmiss,ref objmiss);
			counter = 1;
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (textBox1.Text == "")
				MessageBox.Show("INSERT FILE NAME");
			else
			{
				textBox1.Visible = false;
				label9.Visible = false;
				File.Move(Application.StartupPath + "\\table.docx", "c:\\FlashCartMaker" + textBox1.Text + ".docx");
				File.Copy(Application.StartupPath + "\\table2.docx", Application.StartupPath + "\\table.docx");
				File.Delete(Application.StartupPath + "FlashMakerSecure.txt");
				File.WriteAllText(Application.StartupPath + "\\FlashMakerSecure.txt", "1");
			}

		}



This post has been edited by hamidkhl: 01 September 2009 - 04:51 PM

Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: ERROR: input string is not in a correct format

Posted 02 September 2009 - 05:43 AM

what is the data in the "FlashMakerSecure.txt" file?

just an FYI, the error that you are getting normally occurs when you try to convert a non-numeric value to a number. Say if you try to convert "ABC" into an integer, you will get that error.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1