Trying to deal with variant arrays in c ++.

Code:

VARIANT v; SAFEARRAYBOUND rgb[] = {10,0}; v.vt = VT_ARRAY | VT_VARIANT; v.parray = SafeArrayCreate(VT_VARIANT,1,rgb); long *rgelems; SafeArrayAccessData(v.parray, (void**)&rgelems); for (int c = 0; c < 10; c++) {rgelems[c] = c*100;} SafeArrayUnaccessData(v.parray); for (int c = 0; c < 10; c++) {std::cout << rgelems[c] << " ";} Excel::RangePtr pRange = OldSheet->Range["A1"]["A10"]; pRange->Value2 = rgelems; 

I do not understand the compiler

warning C4800: long *: the boolean value is "true" or "false"

(performance warning) - refers to the string

 Range->Value2 = rgelems; 

And in Excel, the value TRUE is written to the specified range, although normal values ​​are output to the console. What is the problem? Thanks for answers.

  • @OverDozero: I can’t find the documentation, so I’ll ask you: what type of Value2 ? - VladD
  • VladD; I did not quite understand the question: what does it mean what type of value2? msdn.microsoft.com/en-us/library/ ... The difference between Value2 and Value is that Value2 does not support "on-the-fly formatting" for Currency, Double and Date types It seems to me that this is the problem of assigning to a range. I tried to assign symbols to an array, let's say "!". Then it’s normal for the range, namely for numbers - "TRUE". For example, I need to fill 65,000 lines in Excel with numbers from 1 to 65000. It’s pretty long time, and when assigning a range, I get 65000 lines of truth) - OverDozero

0