VBS tutorial: Functions – CSng functions


CSng function

Returns an expression that has been converted toSingleSubtypeVariant


expressionArgument is any valid expression.


In general, you can write code using subtype conversion functions to show that the results of some operations should be represented as a specific data type rather than the default type. For example, in the case of currency or integer operations, useCDblorCSngForces double or single precision operations.

CSngThe function is used to transfer data from other data types toSingleSubtypes are converted to internationally recognized formats. For example, the recognition of decimal separators, such as the thousand separator, depends on the locale of the system.

IfexpressionAn error occurs if it is outside the range allowed by the single subtype.

The following example usesCSngFunction converts a value toSingle:

Dim mydouble1, mydouble2, mysingle1, mysingle2 'mydouble1, mydouble2 are double precision values. Mydouble1 = 75.3421115: mydouble2 = 75.3421555mysingle1 = CSng (mydouble1) 'mysingle1 contains 75.34211. Mysingle2 = CSng (mydouble2) 'mysingle2 contains 75.34216.

Recommended Today

The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]