为什么编译器会说“未声明的标识符”对于我的表格的领域? [英] Why does the compiler say "Undeclared identifier" for my form's fields?
本文介绍了为什么编译器会说“未声明的标识符”对于我的表格的领域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码给我一个错误消息: [Error] Unit1.pas(52):未声明的标识符:'Edit1'。
This code gives me an error message: [Error] Unit1.pas(52): Undeclared identifier: 'Edit1'.
procedure SetTCPIPDNSAddresses(sIPs : String);
begin
SaveStringToRegistry_LOCAL_MACHINE(
'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\' + Edit1.text,
'NameServer', sIPs);
end;
为什么会收到此错误,如何解决?
Why do I get this error, and how do I fix it?
推荐答案
您的代码不是表单的方法,因此无法访问 Edit1
。
Your code isn't a method of the form, and therefore has no access to Edit1
.
将其设为一个表单方法:
Either make it a form method:
type
TForm1=class(TForm)
...
private
procedure SetTCPIPDNSAddresses(sIPs : String);
...
end;
implementation
procedure TForm1.SetTCPIPDNSAddresses(sIPs : String);
begin
...
end;
或更改为接受 Edit1.Text
作为另一个参数:
Or change it to accept the contents of Edit1.Text
as another parameter:
procedure SetTCPIPDNSAddresses(sIPs : String; RegName: String);
begin
SaveStringToRegistry_LOCAL_MACHINE(
'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\' +
RegName, 'NameServer', sIPs);
end;
并调用如下:
SetTCPIPDNSAddresses(sTheIPs, Edit1.Text);
这篇关于为什么编译器会说“未声明的标识符”对于我的表格的领域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文