Search code examples
c++builderinputbox

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


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?


Solution

  • 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).