preload

QTP Math functions – Array/Set Conversions

Posted by Albert Gareev on Feb 19, 2008 | Categories: MathSource code

Parent page: Service Functions – Math (QTP, VBScript)

Convert array to set

Public Function Array2Set(ByVal dvArray, ByVal sSetSeparator)
  Dim Iter
  Dim stResult
 
  If Not isArray(dvArray) Then
    Array2Set = ""
    Exit Function
  End If
  If UBound(dvArray) = -1Then
    Array2Set = ""
    Exit Function
  End If
 
  If sSetSeparator = "" Then
    sSetSeparator = chrSetSeparator
  End If
 
  stResult = CStr(dvArray(0))
  For Iter=1 To UBound(dvArray)
    stResult = stResult & sSetSeparator & CStr(dvArray(Iter))
  Next
 
  Array2Set = stResult
End Function

Convert set to array

Public Function Set2Array(ByVal stSet, ByVal sSetSeparator)
  Dim Iter, dvArray
 
  If sSetSeparator = "" Then
    sSetSeparator = chrSetSeparator
  End If

  dvArray = Split(stSet, sSetSeparator)
  For Iter=0 To UBound(dvArray)
    dvArray(Iter) = Trim(dvArray(Iter))
  Next
 
  Set2Array = dvArray
End Function


  • Leave a Reply

    * Required
    ** Your Email is never shared

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.