こんにちは、C# でボタンを作成しようとしています。添付の txt ファイルの IP アドレスに関するメッセージ ボックスが表示されます。しかし、修正できないエラーが発生しています。戻り値の型が混同されていると思います。ここにコードがあることに常に問題がありました。
private String getIPAddress()
{
String x;
using (TextReader configfile = File.OpenText("PC104Configs.txt"))
while (configfile.Peek() > -1) // If therre are no more characters in this line
{
x = configfile.ReadLine();
if (x.Length == 0)
{
// This is a blank line
continue;
}
if (x.Substring(0, 1) == ";")
{
// This is a comment line
continue;
}
if (x == trueIP)
{
// This is the real deal
testPort = configfile.ReadLine();
testIP = trueIP;
return MessageBox.Show(trueIP);
}
} // End of 'while' there are more characters loop
UnitToTest.Text = "";
MessageBox.Show("Specified Configuration Not Found!");
return (false);
}
private void btnSendConfig_Click(object sender, EventArgs e)
{
getIPAddress();
}