请教,同样的语句得到不同的结果

wxciom 2003-08-20 04:33:45
我的程序中
TEdit *EditA=(TEdit *)FindComponent("EAxleType"+IntToStr(1)) ;

在不同的位置得到了不同的结果
第一个位置结果正确,第二个位置(在for循环中)得到的结果是错误的,为什么?怎样解决?

还有,我还曾碰到一次诡异的问题,我的程序单步执行,上一句执行了,下一句怎么也执行不到,重装bcb就好了,是不是我的bcb有问题?大家也遇到过吗?
...全文
41 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxciom 2003-08-22
  • 打赏
  • 举报
回复
首先谢谢各位的热心
回雪克大侠:我程序调试都是build后再运行的,因为不知道make后就可以,汗~~
源代码:
int an;
bool st;
int *at;
long *aw;
int axn;
int at1;
long aw1;
at=&at1;
aw=&aw1;
int at2;
long aw2;
int cou;
TEdit *EditA;
TEdit *EditAW;

EditA=(TEdit *)FindComponent("EAxleType"+IntToStr(1)) ;
//这一句是想看看EditA的结果对不对

EditA->Text=" ";
EAxleType1->Text=" ";
//比较一下是否等于EditA

EditAW=EAxleWeight1;
an=lWtSys_AxisCount();
cou=1;
for(cou=1;cou<=an;cou++)
{
st=lWtSys_AxisData(cou,at,aw);
EditA=(TEdit *)FindComponent("EAxleType"+IntToStr(cou)) ;
//注意,就在这一句,和上面的那一句相同,但是结果不同,又很大差别

EditAW=(TEdit *)FindComponent("EAxleWeight"+IntToStr(cou)) ;
EditAW->Text=" ";
//所以到这一句程序就执行不下去了

EditA->Text=" ";

if (st)
{
at2=at1;
aw2=aw1;
EditAW->Text=IntToStr(aw1);
switch (at1)
{
case 1:
EditA->Text= "单轴单轮";
break;
case 2:
EditA->Text="单轴双轮";
break;
case 3:
EditA->Text="双联轴单轮";
break;
case 4:
EditA->Text="双联轴单双轮";
break;
case 5:
EditA->Text="双联轴双轮";
break;
case 6:
EditA->Text="三联轴单轮";
break;
case 7:
EditA->Text="三联轴双轮";
break;

}
}
else
EditA->Text="error";
}


后来还出了好多类似的错误,害的我调了整整一夜:( ,最后只有这样才解决,但是很想知道为什么
static int an;
bool st;
static int *at;
static long *aw;
int axn;
static int at1;
static long aw1;
at=&at1;
aw=&aw1;
int at2;
long aw2;
static int cou;
String axletype[8],AxleWt[7],AxleTyp[7];
axletype[1]="单轴单轮";
axletype[2]="单轴双轮";
axletype[3]="双联轴单轮";
axletype[4]="双联轴单双轮";
axletype[5]="双联轴双轮";
axletype[6]="三联轴单轮";
axletype[7]="三联轴双轮";



an=lWtSys_AxisCount();
if (an<6)
{
for(cou=1;cou<=an;cou++)
{
st=lWtSys_AxisData(cou,at,aw);
if (st)
{
AxleTyp[cou]=axletype[at1];
AxleWt[cou]=IntToStr(aw1);
}
else
AxleTyp[1]="error";
}
for(cou=(an+1);cou<=6;cou++)
{
AxleTyp[cou]="";
AxleWt[cou]="";
}
}
else
{
st=lWtSys_AxisData(cou,at,aw);
for(cou=1;cou<=6;cou++)
{
if (st)
{
AxleTyp[cou]=axletype[at1];
AxleWt[cou]=IntToStr(aw1);
}
else
AxleTyp[1]="error";
}
}

Form1->EAxleType1->Text=AxleTyp[1];
Form1->EAxleWeight1->Text=AxleWt[1];
Form1->EAxleType2->Text=AxleTyp[2];
Form1->EAxleWeight2->Text=AxleWt[2];
Form1->EAxleType3->Text=AxleTyp[3];
Form1->EAxleWeight3->Text=AxleWt[3];
Form1->EAxleType4->Text=AxleTyp[4];
Form1->EAxleWeight4->Text=AxleWt[4];
Form1->EAxleType5->Text=AxleTyp[5];
Form1->EAxleWeight5->Text=AxleWt[5];
Form1->EAxleType6->Text=AxleTyp[6];
Form1->EAxleWeight6->Text=AxleWt[6];
wxciom 2003-08-21
  • 打赏
  • 举报
回复
为什么我的问题都很少有人回复?是我问的太低级了还是我的问题太怪了?

我的意思是,我写的一模一样的程序,只是一个在for循环里,得到的结果就不同,很奇怪,不知道什么原因:(
极速小王子 2003-08-21
  • 打赏
  • 举报
回复
不明白!
Friecin 2003-08-21
  • 打赏
  • 举报
回复
最好贴出你的代码.

不过我建议你遇到一些古怪的问题后,尝试Building! 有时候Make的结果的确有问题.
kennidy 2003-08-21
  • 打赏
  • 举报
回复
你还是把整个源代码或函数贴出来
否则没人能够回答你

就像问我的机器为什么会死机一样,不知道前因后果的情况下,天晓得怎么回事
xizhouhawk 2003-08-20
  • 打赏
  • 举报
回复
不明白楼主的意思

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧