Platforms to show: All Mac Windows Linux Cross-Platform

SetVariantArrayValueMBS(v as Variant, index as Integer, value as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method XojoRuntime MBS Util Plugin 16.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets an object from an array of objects inside a variant.
// some part of app builds an array
Var a() as pair

// passes it as Variant somewhere else

Var v as Variant = a

// and later you may want to put values in array without knowing object type for array

// this raises TypeMismatchException
'dim o() as Object = v

// so use plugin

SetVariantArrayValueMBS(v, 0, 1:"Hello")
SetVariantArrayValueMBS(v, 1, 2:"World")

MsgBox a(0).Right+" "+a(1).Right

This function is to allow setting objects in an array inside a variant without known the class used to declare array.
Also updated to work with object, variant, string, date, integer, double, single, boolean, Int64 arrays. Other array types will raise exception.
Be sure to only put objects of right class in the array! Else you risk crashes.

If index is 1 bigger than ubound, we append an element.

Blog Entries

The items on this page are in the following plugins: MBS Util Plugin.

The biggest plugin in space...