确定最高数组值而不循环 [英] Determining the highest array value without cycling through

查看:62
本文介绍了确定最高数组值而不循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


有没有一种简单的方法可以确定数组中的最高点

是否包含值?我正在测量一个数组,最多可容纳255个项目,但是如果

它只包含三个,我不想循环遍历全部255个项目,如果这是'

可能。


任何想法?

谢谢!

解决方案

Jozef写道:

你好,

是否有一种简单的方法来确定数组中包含值的最高点?我正在设计一个数组,最多可容纳255个项目,但是如果
它只包含三个,我不想循环遍历全部255个,如果可能的话。



是的,你可以创建一个单独的计数器变量,让你知道如何填充数组

插槽。或者您可以在最后一次有效输入后在插槽中使用标记。


您也可以使用Redim语句动态调整数组大小,但可能有

性能问题需要考虑。


-

''---------------

''John Mishefske

''---------------


Jozef写道:< blockquote class =post_quotes>你好,

有没有一种简单的方法可以确定数组中包含值的最高点?


除非你在数组中填充时保持跟踪,否则
填充。

我正在确定一个数组的大小最多255个项目,但是如果
它只包含三个,我不想循环通过所有255个,如果
那是可能的。




如果没有
,那么可以检查一个值并退出循环。如果你正在表演,你应该做任何事情

当你循环时对每个值进行一些操作。


我的想法(对于字符串数组,a)是


UBound(拆分(RTrim(加入(a))))


请,让我知道这是如何工作的,因为它是全空气。代码。


Hello,

Is there an easy way to determine the highest point in an array that
contains a value? I''m dimensioning an array to hold up to 255 items, but if
it only contains three, I don''t want to cycle through all 255 if that''s
possible.

any ideas?
Thanks!

解决方案

Jozef wrote:

Hello,

Is there an easy way to determine the highest point in an array that
contains a value? I''m dimensioning an array to hold up to 255 items, but if
it only contains three, I don''t want to cycle through all 255 if that''s
possible.



Yes, you could create a separate counter variable to let you know how may of the array
slots are populated. Or you could use a marker in the slot after the last valid entry.

You could also dynamically resize the array using the Redim statement but there may be
performance issues to consider.

--
''---------------
''John Mishefske
''---------------


Jozef wrote:

Hello,

Is there an easy way to determine the highest point in an array that
contains a value?
Not unless you were keeping track while the array was being
populated.
I''m dimensioning an array to hold up to 255 items, but if
it only contains three, I don''t want to cycle through all 255 if
that''s possible.



It''s possible to check for a value and exit the loop if there isn''t
one. Something you should be doing any way if you''re performing
some operation on each value as you cycle through them.


My idea (for a string array, a) is

UBound(Split(RTrim(Join(a))))

Please, let me know how and if this works as it''s "total air" code.


这篇关于确定最高数组值而不循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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