-1
每當我的表格1試圖打開窗體2我得到這個錯誤...什麼「在mscorlib.dll中發生類型爲」System.FormatException「的未處理異常」是什麼意思?
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
這是什麼意思?這裏是我用於打開Form2的代碼...
if (TimerValue == 5000)
{
this -> timer1 -> Stop();
TimerValue = 0;
Form2^f2 = gcnew Form2;
f2->Show();
MoviePlay = 1;
StreamWriter^ outFile = gcnew StreamWriter("Movie.txt");
String^ Movie = MoviePlay.ToString();
outFile->Write(Movie);
outFile->Close();
this -> button4 ->Visible = false;
this -> button5 ->Visible = false;
this -> label2 ->Visible = false;
this -> button2 ->Visible = false;
this -> button3 ->Visible = false;
FriendString = File::ReadAllText(".\\Rca13\\Friend.txt");
Friend = System::Convert::ToInt32(FriendString);
if (Friend == 1)
{
this -> pictureBox1 -> Load("RetaliationBackground1_Pony1");
}
if (Friend == 2)
{
this -> pictureBox1 -> Load("RetaliationBackground1_Pony2");
}
if (Friend == 3)
{
this -> pictureBox1 -> Load("RetaliationBackground1_Pony3");
}
if (Friend == 4)
{
this -> pictureBox1 -> Load("RetaliationBackground1_SwagMasta");
}
}
是否有任何東西放入此代碼中導致錯誤?
任何想法爲什麼?我確實聲稱它作爲一個變量在頂部通過說String^FriendString; –
@DevonThomas:是的,但是如果價值是「Fred」,你期望它做什麼?這不是一個整數。 –
我認爲命令應該像這樣... IntName = System :: Convert :: ToInt32(NameOfString);我認爲這會將字符串轉換爲數字並將其轉換爲整數...我錯了嗎? –