当前位置:主页>仓库管理软件> 列表

请教大家一个简单的问题!我很是郁闷呀! 找用友财务软件下载

库存管理软件版1楼: 我在主窗体(main)建立全局变量:
type userinfo=record
name:string;
end;
public
auser:userinfo;
然后我在登陆窗体中随便给它赋值:
main.auser.name:=''fdsafa'';
然后我用edit1.text=main.auser.name可是结果什么也没有?
也就是说不管给main.auser.name赋值都显示都是空的? 这是什么原因?? 编译能通过!


(我实在没有分了,谢谢各位前辈了!)

2楼: 在登陆窗体中USES MAIN单元
然后直接引用该变量就可以了 如erp管理软件

3楼: 是啊 我在登陆窗体是用uses main单元.
你说的直接引用是什么意思/? 我好象是直接引用呀

4楼: 全局变量的定义方式有问题吧?
public
auser:userinfo;
这里的public 是什么意思?



type
userinfo=record
name:string;
end;//记录类型的定义

Form1 : TFrom1;
....
public
end;//窗体的定义

auser:userinfo;//全局变量的定义

5楼: to royal1442
public
auser:userinfo;
end ;//全局变量的定义
这些应该没有问题,可是就是没有结果!总是空的??

6楼: 你这个“public”是从那里来的?

库存管理软件版7楼: Form1 : TFrom1;
....
public
end;//
就是这里的呀 我把auser:userinfo;加在里面的呀

8楼: 这个变量是Form1 的共有(public)变量吗?

9楼: 恩 是呀

10楼: 那你的引用变量及其赋值的方式有问题啊!!!
正确的方式是:Form1.AUser.Name := ''AAAA'';
edit1.text=Form1.AUser.Name;
当然,你要确保Form1已经创建!

11楼: 这个应该没有问题
我的方法和你的方法好象是一样的啊?
我在Form1 : TFrom1;
....
public
auser:userinfo;
end;//
我现在试了在另外的登陆窗体form2中给它赋值加入:
form1.auser.name:=''fdsafa'';
showmessage(form1.auser.name);
这时能弹出提示框:fdsafa
可是我去主窗体form1时在使用
showmessage(form1.auser.name);就没有内容了 这是什么原因,难道不能保留?

12楼: 不可能啊!
主窗体是form1吗?
你先试试把auser.name换成一个普通的变量 UserName : string;然后试试行不行! 如用友财务软件下载

13楼: 好象还是不行呀? 这是什么原因
我的代码form2的代码是:
TForm2 = class(TForm)
...
procedure TForm2.Button1Click(Sender: TObject);
begin
form1.auser.code:=''dfsa'';
showmessage(form1.auser.code);
form2.free;
application.CreateForm(TForm1,Form1);
form1.show;//创建form2窗体
end;
这时可以弹出提示dfsa
然后我在主窗体form1中
type userinfo=record
name:string;
end;
type
TForm1 = class(TForm)
...

public
auser: userinfo;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(form1.auser.name);
end
时也能提示可提示的内容为空?
这是怎么回事?

库存管理软件版14楼: procedure TForm2.Button1Click(Sender: TObject);
begin
form1.auser.code:=''dfsa'';
showmessage(form1.auser.code);//你在此处赋值,这个时候Form1还没有创建呢!创建的语句application.CreateForm(TForm1,Form1);还在下面呢!!!!!!!!!!!
form2.free;
application.CreateForm(TForm1,Form1);
form1.show;//创建form2窗体
end;

15楼: 哈哈 我知道了 叩谢royal1442
解决了 我把
procedure TForm2.Button1Click(Sender: TObject);
begin
showmessage(form1.auser.code);
application.CreateForm(TForm1,Form1);
form2.free;
form1.auser.code:=''dfsa'';
form1.show;
end;
真的万分感谢,本人刚学,很菜,什么也不懂实在没有多少分,给你了

16楼: 对了 顺便告诉我怎么样打开头文件,因为我想修改窗体执行顺序
还有空格键的char值是多少? 我忘记了 嘿嘿

17楼: 莫客气,谁都是从菜鸟过来的!

procedure TForm2.Button1Click(Sender: TObject);
begin
form2.Close;

application.CreateForm(TForm1,Form1);
form1.auser.code:=''dfsa'';
showmessage(form1.auser.code);
form1.show;

form2.free;
end;

18楼: project 菜单里面的 View Source 菜单项!

19楼: 哈哈 知道了, 我现在才发现 狂晕呀
放分了 谢谢了

20楼: 多人接受答案了。