how to use InputBox in c++builder with multiple values

╄→尐↘猪︶ㄣ 提交于 2020-01-03 03:34:10

问题


How can I use InputBox to make it take 3 Values. I can make it show just one value by using code:

String input[3];
input[0]= InputBox("paied check", "the value", "");

any help?


回答1:


InputBox() does not support what you are asking for. It is designed for single-value input only.

InputQuery() supports multi-value input, but only in C++Builder XE2 and later, eg:

String prompt[3] = {"value 1:", "value2:", "value 3:"};
String input[3];

if( InputQuery("paied check", EXISTINGARRAY(prompt), EXISTINGARRAY(input)) )
{
    //...
}

Or:

String input[3];

if( InputQuery("paied check", OPENARRAY(String, ("value 1:", "value2:", "value 3:")), EXISTINGARRAY(input)) )
{
    //...
}

Notice the use of the OPENARRAY()/EXISTINGARRAY() macros (from sysopen.h). They are needed because InputQuery() only accepts Delphi-style Open Arrays, not C-style arrays. Open Arrays have an additional parameter (that is hidden in Delphi, but is explicit in C++) to specify the highest index (not the array count) of each array. The macros handle that extra value for you, but they only work for static arrays (which you are using).



来源:https://stackoverflow.com/questions/29884000/how-to-use-inputbox-in-cbuilder-with-multiple-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!