热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

VBA溢出错误在中断模式下消失-VBAOverflowerrordisappearsinbreakmode

Ihavesomecodealongthelinesofthefollowing:我有一些代码如下:redima(1toN)fori1toNa(i

I have some code along the lines of the following:

我有一些代码如下:

redim a(1 to N)
for i = 1 to N
    a(i) = someFunction(i)
Next i

When running it, I get "Run-time error 6: Overflow". And it enters break mode with the line inside the loop: a(i) = someFunction(i) highlighted. To find the error, I step into that function and step over line-by-line. There's no error, it works fine and keeps going. As long as I execute the code this way, staying in break mode & stepping in to someFunction one call at a time, it works, but as soon as I go back to normal execution, the overflow error comes back.

运行时,我得到“运行时错误6:溢出”。并且它与循环内的行进入break模式:a(i)= someFunction(i)突出显示。为了找到错误,我逐步进入该功能并逐步执行。没有错误,它工作正常,并继续前进。只要我以这种方式执行代码,保持中断模式并一次进入someFunction一个调用,它就可以工作,但是一旦我恢复正常执行,溢出错误就会恢复。

Does anyone know how can I get rid of the overflow?

有谁知道我怎么能摆脱溢出?

2 个解决方案

#1


1  

You should provide whole function so we could see the way you declared variables.

您应该提供整个函数,以便我们可以看到您声明变量的方式。

The error is cause by wrong variable declaration. One or more of your variables has no capacity to accept the value (example: you declared variable i as Integer so it cannot accept the value like: i=55000; the maximum value for integer is somewhere around 32000 to 32800)...

错误是由错误的变量声明引起的。您的一个或多个变量无法接受该值(例如:您将变量i声明为整数,因此它不能接受如下值:i = 55000;整数的最大值大约为32000到32800)...

#2


0  

Thanks everyone for helping, I figured out what the problem was. It was something in someFunction causing the overflow, I'm not sure why it didn't happen in break mode, but I fixed what was causing it and it's working now.

谢谢大家的帮助,我弄清楚问题是什么。这是someFunction导致溢出的东西,我不知道为什么它不会在中断模式下发生,但我修复了导致它的原因并且它现在正在工作。


推荐阅读
author-avatar
Annie千寻_535
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有