FAQ Database Discussion Community


Excel VBA - Read range into Variant while maintaining index same as column numbers

excel,vba,indexing,range,variant
I am writing a vba macro in Excel 2013. I have the below code to read a range into a Variant, Dim MyBuffer As Variant With MyWorkSheet MyBuffer = .Range(.Cells(1, NAME_COL), .Cells(10, AGE_COL)).Value End With 'Here NAME_COL = 5, AGE_COL = 9 Now MyBuffer is a 2 dimensional array with...

Assigning one Variant to Another in Excel VBA

excel-vba,variant
So I have two (not adjacent) columns of data on my Excel worksheet, with different numbers of entries. I load their data into two Variants called arr1 and arr2. In the processing that follows, I want to refer to the columns with the fewest and most entries, so I define...

reinterpret_cast / static_cast and undefined behavior

c++,c++11,variant,reinterpret-cast,static-cast
In a variant class I'm working on the raw storage is a char array: alignas(/* the strictest alignment of all types of the variant */) char storage[/* ... */]; The assignment operator is something like: template<class X> void operator=(const X &x) { // ...code for clearing the storage and setting...

How do I represent an Optional String in Go?

string,go,null,optional,variant
I wish to model a value which can have two possible forms: absent, or a string. The natural way to do this is with Maybe String, or Optional<String>, or string option, etc. However, Go does not have variant types like this. I then thought, following Java, C, etc., that the...

VARIANT structure (COM) seems to have no member [on hold]

c++,com,directshow,visual-studio-2015,variant
Using Visual Studio 2015 RC and the Windows SDK 7.1 with this simple DirectShow code (C++ with COM) #include <dshow.h> #include <iostream> int main () { CoInitialize(nullptr); ICreateDevEnum* devEnum = nullptr; CoCreateInstance( CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, reinterpret_cast<void**>(devEnum) ); IEnumMoniker* monikerEnum = nullptr; devEnum->CreateClassEnumerator( CLSID_VideoInputDeviceCategory, &monikerEnum, 0 ); IMoniker* moniker =...

Gradle: android.variantFilter cause build fail after upgrade to Gradle 2.2.1

android,gradle,variant
I am working in an Android project which has many flavors, I used this code in build.gradle to set the package name for each flavor: flavorDimensions "type", "feature" productFlavors { abc { flavorDimension "type" } def { flavorDimension "type" } ABC { flavorDimension "feature" } DEF { flavorDimension "feature" }...

Variant Type Structure (oaidl.h) in c++ for Mac OSX?

c++,xcode,osx,variant,safearray
I'm trying to port my c++ dll developped in windows which make extensive use of Variant (ole/com) type Structure (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms221627%28v=vs.85%29.aspx) . This type is defined in the oaidl.h file of visual studio and is imported in windows with "windows.h". Is there any existing way to use this type in...

What is required in Delphi 2007 to use Variant arrays?

delphi,com,delphi-2007,variant
I'm a newbie in Delphi, using Delphi 2007. I am learning things related to COM programming, in order to make a basic plugin to a program called Retail Pro. I have a little of background in .NET (C#, ASP), NetBeans (Java, JSF) and PHP. Anyway, I'm following this intro tutorial...

Printing variant types in OCaml

printing,ocaml,variant
In my OCaml program, I spend considerable time wring "to_string" for variant types over and over again. Either I need them for debugging purpose, or because I need a specific formatted output. So far, they follow a template such as follows: let rec to_string = function | Var x ->...

pattern matching of variant tag in OCaml

design-patterns,pattern-matching,ocaml,variant
I have the following OCaml substitution function. let rec subst x a f = match f with | Var s -> if s = x then a else Var s | Implies (f1, f2) -> Implies (subst x a f1, subst x a f2) | And (f1, f2) -> And...

C++ Avoiding down-casting or variants

c++,design,variant,downcasting,visitor-pattern
I've been facing a design issue for a while : I am parsing a source code string into a 1-dimensional array of token objects. Depending on the type of a token (litteral, symbol, identifier), it has some token-type-specific data. Litterals have a value, symbols have a symbol type, and identifiers...

Perl : How to match data in entire text

perl,csv,match,multiple-columns,variant
In the following code I am trying to use data from Input File 1 to edit data in Input File 2. But the problem is the code is not able to match or substitute when the possible match text is anywhere other than at the last, towards right. Could you...

How to test if a OleVariant contains an interface

delphi,variant,office-automation
One of the annoying things with working with Excel through its automation interface is the weak typing. A return value can contain anything different types. How do I test if the variant returned by caller is an ExcelRange interface? function TAddInModule.InBank: boolean; var ExcelAppAsVariant: OleVariant; test: string; Caller: OleVariant; begin...

Assigning a variant to a combobox and vice-versa

vba,combobox,variant,store-data
I am trying to assign a variant the "value" of a combobox in a userform in order to store the list so that I can re-assign the "Value" of the variant to the combobox when initializing the userform. Here is the code I am using to assign my variant the...

Compare items in an Array to items in a Variant in VB6

arrays,vba,vb6,variant
I have a Variant in VB6 with thousands of Strings. I also have an array of fixed length. I need to compare the contents of each and add the ones that match to a list. if array(i) = variant(1,i) then 'add to list End if I cannot figure out how...