小编Leo*_*ves的帖子

在组合框和列表框上使用 ListFillRange 的表列

我一直在尝试让组合框使用表的第一列作为其范围输入,但它似乎什么也没做。

前任。

sheet1.ComboBox1.ListFillRange = "table1"
sheet1.ComboBox1.ListFillRange = "table1[Column 1]"
Run Code Online (Sandbox Code Playgroud)

两者都不起作用。即使使用表单 ComboBox 而不是 activeX 并将“table1”或“table1[Column 1]”作为输入范围也是如此。我还尝试在字符串的开头添加“=”(“=table1”等)。

然后我决定命名表范围,因为使用 .ListFillRange 时其他命名范围可以工作:

sheet1.ComboBox1.ListFillRange = "RangeName"
Run Code Online (Sandbox Code Playgroud)

这也不起作用(我认为因为命名范围只是对我最初尝试的同一事物的引用)。

那么我是否只需要制定一个正常的公式来查找第一列所在的范围,或者我是否遗漏了某些内容?(这确实看起来应该是一个功能,因为它很简单,但我想没有什么比我们希望的那么简单)

excel controls vba

1
推荐指数
1
解决办法
7473
查看次数

了解神秘工作的递归二进制搜索算法

在赋值时,我必须使用递归二进制搜索算法输出索引而不是True/False而不修改参数.我度过了一段非常艰难的时期,但在诉诸半试错之后,我偶然发现了这个烂摊子:

#include <iostream>
#include <math.h>
#include <climits>

using namespace std;


int BinarySearch(int arr[], int len, int target) {

    int temp = 0;
    int mid = len/2;

    if (len <= 0) return INT_MIN;  // not found
    if (target == arr[mid]){
        return mid; // found
    }

    if (target < arr[mid]){
        temp = BinarySearch(arr, mid, target);
    }

    else {
        temp = mid+1 + BinarySearch(arr+mid+1, len-mid-1, target);              
    }
}
Run Code Online (Sandbox Code Playgroud)

即使在通过可视化工具运行之后,我也完全不知道它为什么会起作用.它对更改的代码非常敏感,当它无法找到目标时我无法输出-1,所以我至少总是输出一个负数.

我真的不需要它固定,我只是想知道它是如何工作的,因为看起来甚至没有使用递归调用的输出.谢谢.

c++ algorithm search binary-search c++11

-1
推荐指数
1
解决办法
127
查看次数

标签 统计

algorithm ×1

binary-search ×1

c++ ×1

c++11 ×1

controls ×1

excel ×1

search ×1

vba ×1