none
Data conversion after Split function RRS feed

  • Question

  • Hi,

    I am calling a VBA function and I am not able to convert the values in the variant after using the Split function.

    Private Function BuildFormula(Criteria As String,....

    varOr = Split(Criteria, ";")


    The Criteria I am passing to the function is f.i. "5;l"

    varOr(0) contains "5" but I need the value 5 for further execution.

    Tought if I put:

    varOr(intCount) = CDbl(varOr(intCount))

    I would have it but strange enough it remains the string 5.

    A work-around was to use another variant to convert the values but I would like to know why this is not possible in the original variant.

    Kind regards,

    JP Ronse.

    Wednesday, March 28, 2018 4:33 PM

Answers

  • Split returns an array of strings, not of variants. Even if you assign a number to one of the array elements, it remains a string...

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Proposed as answer by Terry Xu - MSFT Thursday, March 29, 2018 3:20 AM
    • Marked as answer by JP Ronse Thursday, March 29, 2018 3:04 PM
    Wednesday, March 28, 2018 5:14 PM

All replies

  • Split returns an array of strings, not of variants. Even if you assign a number to one of the array elements, it remains a string...

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Proposed as answer by Terry Xu - MSFT Thursday, March 29, 2018 3:20 AM
    • Marked as answer by JP Ronse Thursday, March 29, 2018 3:04 PM
    Wednesday, March 28, 2018 5:14 PM
  • Thanks Hans
    Thursday, March 29, 2018 3:04 PM