在VB 6中将程序编译为EXE的问题 [英] Issue with compiling a program into an EXE, VB 6

查看:113
本文介绍了在VB 6中将程序编译为EXE的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近按照我的要求编辑了一位同学的数据收集软件。当我在Visual Basic 6中运行时,该程序运行良好,但是理想情况下,我希望将该程序编译为.exe文件,以便可以从任何PC上运行它。但是,当我选择将其转换为exe时,在编译时会出现以下错误:

I have recently edited a fellow student's data collection software to my specifications. The program works fine when I run within Visual Basic 6, however ideally I would like to compile the program into an .exe file so I can run it from any PC. However, when I select the option to turn it into an exe, I get the following error while its compiling:

编译错误:未定义子函数或函数。

Compile Error: Sub or Function not defined.

我很好奇为什么我的程序将在Visual Basic中运行,但无法编译为exe。

I was curious why my program will run from within Visual Basic, but can't compile into an exe. Any fixes/suggestions would be greatly appreciated!

推荐答案

在每个文件的开头,都写 显式选项

at the begining of every file, write "option explicit". This changes vb behavior from weak typed to strong typed.

这意味着当您将字符串放入整数时,vb会立即告诉您,或者至少在您按下运行时。在弱类型模式下,程序将一直运行直到遇到错误,例如未定义Sub或Function,然后崩溃。

What this means is that when you put a string into an integer, then the vb will tell you right away, or at least when you press "run". In a weak typed mode, the program will run until it encounters a fault, like "Sub or Function not defined" then crash.

当编译为 exe时,vb需要做额外的完整性检查,就像显式选项一样。这就是为什么正常执行时看不到问题的原因。它仍然存在,潜伏着,但您可能不会执行有问题的路线。

When you compile into an "exe", vb needs to do extra sanity checks much like "option explicit" would do. This is why you don't see the problem while normal execution. It is still there, lurking, but you probably don't execute the problematic line.

在每个vb源文件中使用此关键字非常重要,否则,您将一直遇到类似的问题。

It is very important that you use this keyword in every vb source file you have, otherwise you'll see problems like this all the time.

这篇关于在VB 6中将程序编译为EXE的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆