How to convert 'double' to ' VARIANT' - visual-c++

In my application via VC 2012, the ready function needs 'VARIANT' value as an input. I have a 'double' variable. Below is what I tired the conversion which didn't work. have searched online and failed to find the answer. Please advise. Thanks.
double db=19;
VARIANT v;
v.dblVal=19;

Below comment from one of window file will provide brief about supported data type of VARIANT
/*
* VARENUM usage key,
*
* * [V] - may appear in a VARIANT
* * [T] - may appear in a TYPEDESC
* * [P] - may appear in an OLE property set
* * [S] - may appear in a Safe Array
* * [C] - supported by class _variant_t
*
*
* VT_EMPTY [V] [P] nothing
* VT_NULL [V] [P] SQL style Null
* VT_I2 [V][T][P][S][C] 2 byte signed int
* VT_I4 [V][T][P][S][C] 4 byte signed int
* VT_R4 [V][T][P][S][C] 4 byte real
* VT_R8 [V][T][P][S][C] 8 byte real
* VT_CY [V][T][P][S][C] currency
* VT_DATE [V][T][P][S][C] date
* VT_BSTR [V][T][P][S][C] OLE Automation string
* VT_DISPATCH [V][T][P][S][C] IDispatch *
* VT_ERROR [V][T] [S][C] SCODE
* VT_BOOL [V][T][P][S][C] True=-1, False=0
* VT_VARIANT [V][T][P][S] VARIANT *
* VT_UNKNOWN [V][T] [S][C] IUnknown *
* VT_DECIMAL [V][T] [S][C] 16 byte fixed point
* VT_I1 [T] signed char
* VT_UI1 [V][T][P][S][C] unsigned char
* VT_UI2 [T][P] unsigned short
* VT_UI4 [T][P] unsigned short
* VT_I8 [T][P] signed 64-bit int
* VT_UI8 [T][P] unsigned 64-bit int
* VT_INT [T] signed machine int
* VT_UINT [T] unsigned machine int
* VT_VOID [T] C style void
* VT_HRESULT [T] Standard return type
* VT_PTR [T] pointer type
* VT_SAFEARRAY [T] (use VT_ARRAY in VARIANT)
* VT_CARRAY [T] C style array
* VT_USERDEFINED [T] user defined type
* VT_LPSTR [T][P] null terminated string
* VT_LPWSTR [T][P] wide null terminated string
* VT_FILETIME [P] FILETIME
* VT_BLOB [P] Length prefixed bytes
* VT_STREAM [P] Name of the stream follows
* VT_STORAGE [P] Name of the storage follows
* VT_STREAMED_OBJECT [P] Stream contains an object
* VT_STORED_OBJECT [P] Storage contains an object
* VT_BLOB_OBJECT [P] Blob contains an object
* VT_CF [P] Clipboard format
* VT_CLSID [P] A Class ID
* VT_VECTOR [P] simple counted array
* VT_ARRAY [V] SAFEARRAY*
* VT_BYREF [V] void* for local use
*/
You should use _variant_t instead of VARIANT.
Below code will convert your double value to variant,
_variant_t var(10.52);

Related

Why i cant use acos function

I have a problem with this function. Excel return #name error.
=ACOS(COS(RADIANS(90-B3)) * COS(RADIANS(90-$G$3)) + SIN(RADIANS(90-B3)) * SIN(RADIANS(90-$G$3)) * COS(RADIANS(C3-$G$4))) * 6371

Typescript Cannot find name 'functionName'

I have included the typings and referenced them.
I'm not sure if the typings are correct, since I don't know how to write them. But this is what I did:
// This is where I'm getting Cannot find name 'Polylabel'
geometry: polylabel(feat.geometry.coordinates)
I have included these typings:
declare module "polylabel" {
/**
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
*
* #name polylabel
* #function
* #param {Array<number>} polygon - Given polygon coordinates in GeoJSON-like format
* #param {number} precision - Precision (1.0 by default)
* #param {boolean} debug - Debugging for Console
* #return {Array<number>}
* #example
* var p = polylabel(polygon, 1.0);
*/
function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[];
namespace polylabel {}
export = polylabel;}
And referenced it as follow:
/// <reference path="globals/#types/polylabel/index.d.ts" />
Instead of using /// <reference... add the .d.ts file to your tsconfig.json, on the "Files" section.
To use this module do this:
import * as polylabel from 'polylabel';
polylabel.polylabel(...)
or (If you are using namespaces and not imports)
polylabel.polylabel(...)

Compile error of erfc function

I tried to use erfc but it says argument not optional.
An example is given below
For j = 0 To 150
f = 1
For m = 1 To j
f = f * m
Next
Application.WorksheetFunction.Erf = (Application.WorksheetFunction.Erf) + (-1) ^ j * b ^ (2 * j + 1) / ((2 * j + 1) * f)
Next
Application.WorksheetFunction.ErfC = 1 - 2 / Sqr(3.14) * Application.WorksheetFunction.Erf
MsgBox (Application.WorksheetFunction.ErfC)
xf1 = (wa + 2 * sp) * q / (4 * cl ^ 2 * 3.14 * hf)
xf2 = Exp(b ^ 2) * Application.WorksheetFunction.ErfC
xf3 = 2 * b / Sqr(3.14) - 1
xf = xf1 * (xf2 + xf3)
According to the MSDN documentation at least one parameter needs to be passed to the Erf method:
Name Required/Optional Data Type Description
Arg1 Required Variant Lower_limit - the lower bound for integrating ERF.
Arg2 Optional Variant Upper_limit - the upper bound for integrating ERF.
If omitted, ERF integrates between zero and
lower_limit.
Therefore, calling it with zero parameters (e.g. Application.WorksheetFunction.Erf) will give you an "argument not optional" error.
You also won't be able to set Erf to a value, i.e.
Application.WorksheetFunction.Erf = ...
is invalid.

Why isn't Doxygen documenting public class functions for my C# code?

I want to use Doxygen to document my c# code. So, I'm doing a trial run. So far it is not documenting the public functions in my test class. Here is my code:
/**
* #file doxyTest.cs
* #author Jon Plotner <plotnus#gmail.com>
* #version 1.0
*
* #section DESCRIPTION
* A test class for testing and running doxygen
*/
public class doxyTest{
/**
* Method1 adds the two numbers
* #param varA the first number to be added
* #param varB the second number to be added
* #returns An int which is the sum of varA and varB
*/
public int method1(int varA, int varB){
return a+b;
}
/**
* Method 2 compares the value of two numbers
* #param varA the first number
* #param varB the second number
* #return A bool, true if varA < varB
*/
public bool lessThan(int varA, int varB){
}
}
In the HTML output from Doxygen the "doxyTest Class Reference" is empty save for these lines:
The documentation for this class was generated from the following file:
*source/file1/doxyTest.cs
What am I doing wrong and how can I fix this?
The help is much appreciated as I've been trying to fix it myself for hours.

how to Calculate google map circle radius js to C#

I know how to use the javascript to calculate the radius by using the below code
var center = new google.maps.LatLng(3.2987599, 102.6872022);
var latLng = new google.maps.LatLng(3.0987599, 101.6872022);
var distanceInMetres = google.maps.geometry.spherical.computeDistanceBetween(center, latLng);
But how to convert the google.maps.geometry.spherical.computeDistanceBetween into C# function?
Distance between 2 points: (lat1,lon1) to (lat2,lon2)
distance = acos(
cos(lat1 * (PI()/180)) *
cos(lon1 * (PI()/180)) *
cos(lat2 * (PI()/180)) *
cos(lon2 * (PI()/180))
+
cos(lat1 * (PI()/180)) *
sin(lon1 * (PI()/180)) *
cos(lat2 * (PI()/180)) *
sin(lon2 * (PI()/180))
+
sin(lat1 * (PI()/180)) *
sin(lat2 * (PI()/180))
) * 3959
3959 is the Earth radius in Miles. Replace this value with
radius in KM, (or any other unit), to get results on the same unit.
You can verify your implementation by comparing to this worked example:
i have write the C# solution to calculate the distance to convert
var distanceInMetres = google.maps.geometry.spherical.computeDistanceBetween(center, latLng);
into C#. Below is the code i have using. 6371 is the radius of the Earth.
//Calculate distance earth between 2 coordinate point
double e = lat * (Math.PI / 180);
double f = lng * (Math.PI / 180);
double g = lat2 * (Math.PI / 180);
double h = lng2 * (Math.PI / 180);
double i =
(Math.Cos(e) * Math.Cos(g) * Math.Cos(f) * Math.Cos(h)
+ Math.Cos(e) * Math.Sin(f) * Math.Cos(g) * Math.Sin(h)
+ Math.Sin(e) * Math.Sin(g));
double j = Math.Acos(i);
double k = (6371 * j); //Distance in KM
The distance between 2 lat/long points can be calculated with the haversine formula, which is described here http://en.wikipedia.org/wiki/Haversine_formula
There also is another question here at stackoverflow about more or less the same issue: Calculate distance between two latitude-longitude points? (Haversine formula)

Resources