这回请教VB高手一个问题

fulpchcl

知名会员
注册
2002-04-04
消息
492
荣誉分数
1
声望点数
128
我有一个project在VB里运行没事,但make成exe file后老说是除数是0。
check code, 问题出在对一个form的menu的Caption赋值时:

aform.abWindow.Caption = "abc"

我实在想不出它有哪儿错。

请教各位像这类问题如何找出它的错。

多谢。
 
你make的exe和你的vb ide是不是不在同一个目录?会不会使用了指向当前目录的文件?你根据什么判断是上面这个语句造成错误?是不是把这一行remark掉就一切正常了?
 
最初由 klin 发布
你make的exe和你的vb ide是不是不在同一个目录?会不会使用了指向当前目录的文件?你根据什么判断是上面这个语句造成错误?是不是把这一行remark掉就一切正常了?

1. 在不在同一个目录没有关系。
2. I put statements like this:
msgbox("before assign")
aform.abWindow.Caption = "abc"
msgbox("after assign")

what I got is:

msg box [before assign],

Run-time error '11:
Division by zero

msg box[after assign],

exe abortion.

3. 因为有好几句assign statments, remark this one , run-time error will appear in next assign statement.

多谢 :thanks: :thanks: :thanks:
 
The cause is unknown from your description. Here are three things off my head:
1. Do you make EXE as P-Code or native code? Suppose you're using VB6 notVisual Studio.NET. Try switch the option when you're making EXE. Another thing is to adjust the options for code Generation & Code optimization in the same window, cannot remember the details, it's not my tool for more than two years.
2. put your suspecting code into exception handling mechanism, using "on error go to TagName".

3. The cause may not be the assign statements, even it seems like. Looking around...

If you figure it out, post the result, please.
 
最初由 AlgonquinStuden 发布
The cause is unknown from your description. Here are three things off my head:
If you figure it out, post the result, please.
Thanks. :thanks:
What I am using is VB5 SP3.
More likely I feel the problem could be in environment, not the code itself.
I will try what you suggested and let you know the result.

Thanks again.

Anyone else has a good idea?
 
Usually this issue happens with hardware(cpu)/software(os, service pack, etc.) compatibility when you run the exe on different machine.

In your case, it's more likely because different runtime dlls are used when switching to EXE from IDE. The cause of the runtime dll returning the error maybe is a piece of code in your program. IMHO, it's hard... it takes times to figure it out whether your code or not. Possibly the cause is a bug in runtime dlls or the library dlls the program using, as you said, it's enviroment issue.

Most likely, the P-Code EXE could run without error. If you don't mind, you may settle with P-Code.

Good Luck!
 
最初由 AlgonquinStuden 发布
Most likely, the P-Code EXE could run without error. If you don't mind, you may settle with P-Code.

Good Luck!
I always use the default setting. I have tried p-code, but still got the error message. I think I am approching the problem.
Thanks a lot.
BTW, what does the p-code mean?
 
P-Code : Pseudo-code, intermediate form of execution code other than binary execution code(cpu sets). VB language is originally interpreted, not compiled .

If the P-Code didn't work, then you may catch the exception in VB IDE. By default, VB IDE just break when the error happened in class module. Change the Tools-Options-General-Error Trapping to "Break on All errors", you could catch the error in IDE, you may have a clue to find the cause.

Try using "On Error Resume Next" to work around the issue since the IDE works.

Another resort is to debug the EXE in VC, this is a different story.

It seems like that you have a clue in your code/enviroment. Keep going...
 
最初由 AlgonquinStuden 发布
Usually this issue happens with hardware(cpu)/software(os, service pack, etc.) compatibility when you run the exe on different machine.

Good Luck!

Finally found the problem. You are right. The real problem is an OCX is not compatiblility.
一身汗。
多谢。:thanks:
 
那应该在什么系统上make EXE,才能然2000、XP都能用呢?
 
后退
顶部