Bool to int excel

Как преобразовать логическое значение true / false в число (1/0) или текст в Excel?

Иногда формулы Excel возвращают логические значения (ИСТИНА или ЛОЖЬ) в Excel. И вы можете отредактировать исходную формулу, чтобы легко преобразовать логические значения (ИСТИНА или ЛОЖЬ) в число (1 или 0) или текст в Excel.

  • Преобразование логических значений (ИСТИНА или ЛОЖЬ) в число (1 или 0) в Excel
  • Преобразование логических значений (ИСТИНА или ЛОЖЬ) в текст в Excel
  • Еще статьи о преобразовании чисел в текст …

Преобразование логических значений (ИСТИНА или ЛОЖЬ) в число (1 или 0) в Excel

В этом разделе я расскажу о трех методах преобразования логических значений (ИСТИНА или ЛОЖЬ) в число (1 или 0) в Excel.  

Добавить — перед исходной формулой

Измените исходную формулу на = — (original_formula), и логические значения будут автоматически преобразованы в число 1 или 0. Например, исходная формула = B2> C2, вы можете изменить его на =— (B2> C2).

Объедините функцию INT и исходную формулу

Объедините функцию INT и исходную формулу как = INT (original_formula), и логические значения будут автоматически преобразованы в число 1 или 0. Скажем, исходная формула = B2> C2, и вы можете преобразовать его в =INT(B2> C2).

Умножить исходную формулу на 1

Вы можете умножить возвращаемые логические значения (ИСТИНА или ЛОЖЬ) на 1, и тогда ИСТИНА изменится на 1, а ЛОЖЬ — на 0. Предполагая, что исходная формула имеет вид = B2> C2, вы можете изменить его на =(B2> C2) * 1.

Внимание: Вы также можете разделить исходную формулу на 1 или добавить 0 к исходной формуле, чтобы изменить возвращаемое значение ИСТИНА на 1 и ЛОЖЬ на 0. Следуйте примеру выше, измените исходную формулу на =(B2> C2) / 1 or =(B2> C2) +0.

Преобразование логических значений (ИСТИНА или ЛОЖЬ) в текст в Excel

Если вы хотите преобразовать логические значения (ИСТИНА или ЛОЖЬ) в определенный текст, говорит Да или Нет, вы можете изменить формулу, как показано ниже:

= ЕСЛИ (исходная_формула; «Да»; «НЕТ»)

Например, исходная формула = B2> C2, вы можете изменить формулу на =ЕСЛИ(B2> C2,»Да нет»). Эта новая формула изменит ИСТИНА на Да и ЛОЖЬ на Нет. См. Снимок экрана:

Внимание: В новой формуле Да и Нет — это указанные тексты, на которые вы измените логические значения, и вы можете изменить их на любые тексты по своему усмотрению.


Статьи по теме:


Лучшие инструменты для работы в офисе

Kutools for Excel Решит большинство ваших проблем и повысит вашу производительность на 80%

  • Снова использовать: Быстро вставить сложные формулы, диаграммы и все, что вы использовали раньше; Зашифровать ячейки с паролем; Создать список рассылки и отправлять электронные письма …
  • Бар Супер Формулы (легко редактировать несколько строк текста и формул); Макет для чтения (легко читать и редактировать большое количество ячеек); Вставить в отфильтрованный диапазон
  • Объединить ячейки / строки / столбцы без потери данных; Разделить содержимое ячеек; Объединить повторяющиеся строки / столбцы… Предотвращение дублирования ячеек; Сравнить диапазоны
  • Выберите Дубликат или Уникальный Ряды; Выбрать пустые строки (все ячейки пустые); Супер находка и нечеткая находка во многих рабочих тетрадях; Случайный выбор …
  • Точная копия Несколько ячеек без изменения ссылки на формулу; Автоматическое создание ссылок на несколько листов; Вставить пули, Флажки и многое другое …
  • Извлечь текст, Добавить текст, Удалить по позиции, Удалить пробел; Создание и печать промежуточных итогов по страницам; Преобразование содержимого ячеек в комментарии
  • Суперфильтр (сохранять и применять схемы фильтров к другим листам); Расширенная сортировка по месяцам / неделям / дням, периодичности и др .; Специальный фильтр жирным, курсивом …
  • Комбинируйте книги и рабочие листы; Объединить таблицы на основе ключевых столбцов; Разделить данные на несколько листов; Пакетное преобразование xls, xlsx и PDF
  • Более 300 мощных функций. Поддерживает Office/Excel 2007-2021 и 365. Поддерживает все языки. Простое развертывание на вашем предприятии или в организации. Полнофункциональная 30-дневная бесплатная пробная версия. 60-дневная гарантия возврата денег.

вкладка kte 201905


Вкладка Office: интерфейс с вкладками в Office и упрощение работы

  • Включение редактирования и чтения с вкладками в Word, Excel, PowerPoint, Издатель, доступ, Visio и проект.
  • Открывайте и создавайте несколько документов на новых вкладках одного окна, а не в новых окнах.
  • Повышает вашу продуктивность на 50% и сокращает количество щелчков мышью на сотни каждый день!

офисный дно

Комментарии (0)


Оценок пока нет. Оцените первым!

Содержание

  1. Type conversion functions
  2. Syntax
  3. Return types
  4. Remarks
  5. CBool function example
  6. CByte function example
  7. CCur function example
  8. CDate function example
  9. CDbl function example
  10. CDec function example
  11. CInt function example
  12. CLng function example
  13. CSng function example
  14. CStr function example
  15. CVar function example
  16. See also
  17. Support and feedback
  18. How to Use Boolean Values (Logical Values) in Excel
  19. What To Know
  20. What is a Boolean Value?
  21. Boolean Values and Spreadsheet Logical Functions
  22. Boolean Values and Arithmetic Functions
  23. Converting TRUE and FALSE to 1 and 0
  24. Boolean Values and Excel Formulas

Type conversion functions

Each function coerces an expression to a specific data type.

Syntax

  • CBool(expression)
  • CByte(expression)
  • CCur(expression)
  • CDate(expression)
  • CDbl(expression)
  • CDec(expression)
  • CInt(expression)
  • CLng(expression)
  • CLngLng(expression) (Valid on 64-bit platforms only.)
  • CLngPtr(expression)
  • CSng(expression)
  • CStr(expression)
  • CVar(expression)

The required expression argument is any string expression or numeric expression.

Return types

The function name determines the return type as shown in the following:

Function Return type Range for expression argument
CBool Boolean Any valid string or numeric expression.
CByte Byte 0 to 255.
CCur Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
CDate Date Any valid date expression.
CDbl Double -1.79769313486231E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
CDec Decimal 79,228,162,514,264,337,593,543,950,335 for zero-scaled numbers, that is, numbers with no decimal places. For numbers with 28 decimal places, the range is 7.9228162514264337593543950335. The smallest possible non-zero number is 0.0000000000000000000000000001.
CInt Integer -32,768 to 32,767; fractions are rounded.
CLng Long -2,147,483,648 to 2,147,483,647; fractions are rounded.
CLngLng LongLong -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807; fractions are rounded. (Valid on 64-bit platforms only.)
CLngPtr LongPtr -2,147,483,648 to 2,147,483,647 on 32-bit systems, -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 on 64-bit systems; fractions are rounded for 32-bit and 64-bit systems.
CSng Single -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.
CStr String Returns for CStr depend on the expression argument.
CVar Variant Same range as Double for numerics. Same range as String for non-numerics.

If the expression passed to the function is outside the range of the data type being converted to, an error occurs.

Conversion functions must be used to explicitly assign LongLong (including LongPtr on 64-bit platforms) to smaller integral types. Implicit conversions of LongLong to smaller integrals are not allowed.

In general, you can document your code using the data-type conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CCur to force currency arithmetic in cases where single-precision, double-precision, or integer arithmetic normally would occur.

You should use the data-type conversion functions instead of Val to provide internationally aware conversions from one data type to another. For example, when you use CCur, different decimal separators, different thousand separators, and various currency options are properly recognized depending on the locale setting of your computer.

When the fractional part is exactly 0.5, CInt and CLng always round it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2. CInt and CLng differ from the Fix and Int functions, which truncate, rather than round, the fractional part of a number. Also, Fix and Int always return a value of the same type as is passed in.

Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.

A CVDate function is also provided for compatibility with previous versions of Visual Basic. The syntax of the CVDate function is identical to the CDate function; however, CVDate returns a Variant whose subtype is Date instead of an actual Date type. Since there is now an intrinsic Date type, there is no further need for CVDate. The same effect can be achieved by converting an expression to a Date, and then assigning it to a Variant. This technique is consistent with the conversion of all other intrinsic types to their equivalent Variant subtypes.

The CDec function does not return a discrete data type; instead, it always returns a Variant whose value has been converted to a Decimal subtype.

CBool function example

This example uses the CBool function to convert an expression to a Boolean. If the expression evaluates to a nonzero value, CBool returns True, otherwise, it returns False.

CByte function example

This example uses the CByte function to convert an expression to a Byte.

CCur function example

This example uses the CCur function to convert an expression to a Currency.

CDate function example

This example uses the CDate function to convert a string to a Date. In general, hard-coding dates and times as strings (as shown in this example) is not recommended. Use date literals and time literals, such as #2/12/1969# and #4:45:23 PM# , instead.

CDbl function example

This example uses the CDbl function to convert an expression to a Double.

CDec function example

This example uses the CDec function to convert a numeric value to a Decimal.

CInt function example

This example uses the CInt function to convert a value to an Integer.

CLng function example

This example uses the CLng function to convert a value to a Long.

CSng function example

This example uses the CSng function to convert a value to a Single.

CStr function example

This example uses the CStr function to convert a numeric value to a String.

CVar function example

This example uses the CVar function to convert an expression to a Variant.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

Источник

How to Use Boolean Values (Logical Values) in Excel

Boolean values make for great yes-or-no values in calculations

What To Know

  • Boolean values are True or False, 1 or 0.
  • Use the words in all caps to represent Boolean values. Ex: TRUE
  • Use logical functions, like IF, OR, and AND, with Boolean values.

This article explains how to use Boolean values in Microsoft Excel spreadsheets. These instructions apply to Excel versions 2019, 2016, 2013, 2010, and Excel for Microsoft 365.

What is a Boolean Value?

A Boolean value, which is sometimes called a logical value, is one of several types of data used in spreadsheets in applications like Excel and Google Sheets. Named after the 19th-century mathematician George Boole, Boolean values are part of a branch of algebra known as Boolean algebra or Boolean logic.

Boolean logic is vital to all computer technology, not just spreadsheet programs, and rests on the concept that all values can be reduced to either TRUE or FALSE—or, because computer technology is based on the binary number system, either 1 or 0.

Boolean Values and Spreadsheet Logical Functions

Boolean values in spreadsheet programs are most often created using the logical group of functions such as the IF function, the AND function, and the OR function.

In these functions, Boolean values are the input source for one of the function’s arguments, or they can form the output or results of a function that is evaluating other data in the worksheet.

For example, the first argument of the IF function in row 4—the logical test argument—is required to return a Boolean value as an answer. The argument must always evaluate a condition that can only ever result in a TRUE or FALSE response. As a result:

  • If the argument returns an answer of TRUE, the function performs one action. In this example, it multiplies the data in cell A2 by 25.
  • If the argument returns an answer of FALSE, the function performs a different action. In this case, it multiplies the data in cell A2 by 10.

Boolean Values and Arithmetic Functions

Unlike logical functions, most functions in Excel and Google Sheets that perform arithmetic operations such as SUM, COUNT, and AVERAGE ignore Boolean values when they are in cells included in a function’s arguments.

For example, in the example image, the COUNT function in row 5, which only counts cells containing numbers, ignores the TRUE and FALSE Boolean values located in cells A3, A4, and A5 and returns an answer of 0.

Converting TRUE and FALSE to 1 and 0

To have Boolean values included in the calculations of arithmetic functions, you must first convert them to numeric values before passing them to the function. Two ways of accomplishing this step are to:

  • Multiply the Boolean values by one (as shown by the formulas in rows 7 and 8 of the example, which multiply the values TRUE and FALSE in cells A3 and A4 by one).
  • Add a zero to each Boolean value (as shown by the formula in row 9 of the example, which adds 0 to the value TRUE in cell A5).

These operations have the effect of converting the value TRUE in cells A3 and A5 to 1 and the value FALSE in cell A4 to 0. As a result, the COUNT function in row 10, which totals number data in cells A7 to A9, returns a result of 3 rather than 0.

Boolean Values and Excel Formulas

Unlike arithmetic functions, formulas in Excel and Google Sheets that carry out arithmetic operations such as addition and subtraction are happy to read Boolean values as numbers without the need for conversion. Such formulas automatically set TRUE equal to 1 and FALSE equal to 0.

As a result, the addition formula in row 6 in the example image,

reads the data in the three cells as:

and returns an answer of 2 accordingly.

Get the Latest Tech News Delivered Every Day

Источник

In this video, we’ll look at some ways you can convert TRUE and FALSE values in Excel to 1s and 0s.

When working with more advanced formulas, especially array formulas, you need to know how to convert TRUE and FALSE values in Excel to their numeric equivalents, 1 and 0.

This is best explained with an example.

In this worksheet, I have a list of fruit names.

Let’s count all the names with more than 5 characters.

I’ll first get the length of each name with the LEN function.

If I give LEN the entire range, results spill onto the worksheet into a dynamic array.

Now, to get a TRUE or FALSE result, I’ll convert the formula to a logical expression that checks if the length is greater than 5.

=LEN(B5:B26)>5

The result is a set of boolean values. For each name, we get a result of TRUE or FALSE.

Now, if I feed this range into the SUM function, we get zero as the result.

Why is that?

This is because TRUE and FALSE are logicals, not numbers.

And the SUM function only works with numbers.

We need a way to convert these TRUE and FALSE values to their numeric equivalents, 1 and zero.

A good way to do this is with any math operation.

I’ll first wrap the formula in parentheses in order to control the order of operations. We want the numeric conversion to happen last.

One option is to simply add zero.

=(LEN(B5:B24)>5)+0

Or, I can multiply by 1

I can also use the N function which converts values to numbers.

=N(LEN(B5:B24)>5)

My personal favorite is to use a double negative, because it’s easy to type, and visually, it signals a numeric conversion.

=--(LEN(B5:B24)>5)

But each method works fine.

In each case, we get either 1 or zero.

Now that we’ve converted the booleans to numbers, the SUM formula works properly, and we can see that 11 fruits have names with more than 5 characters.

Finally, I’ve been using a helper column to more easily visualize these operations, but typically, we’d put everything into a single formula.

I can just copy the formula from C5, and then paste into the SUM function.

=SUM(--(LEN(B5:B24)>5))

If I check the operation inside sum, with the F9 key, I can see that we get the same array, and the SUM function returns the same result.

I can now remove the helper column, and everything will still work.

What To Know

  • Boolean values are True or False, 1 or 0.
  • Use the words in all caps to represent Boolean values. Ex: TRUE
  • Use logical functions, like IF, OR, and AND, with Boolean values.

This article explains how to use Boolean values in Microsoft Excel spreadsheets. These instructions apply to Excel versions 2019, 2016, 2013, 2010, and Excel for Microsoft 365.

What is a Boolean Value?

Boolean value, which is sometimes called a logical value, is one of several types of data used in spreadsheets in applications like Excel and Google Sheets. Named after the 19th-century mathematician George Boole, Boolean values are part of a branch of algebra known as Boolean algebra or Boolean logic.

Boolean logic is vital to all computer technology, not just spreadsheet programs, and rests on the concept that all values can be reduced to either TRUE or FALSE—or, because computer technology is based on the binary number system, either 1 or 0.

Boolean Values and Spreadsheet Logical Functions

Boolean values in spreadsheet programs are most often created using the logical group of functions such as the IF function, the AND function, and the OR function.

In these functions, Boolean values are the input source for one of the function’s arguments, or they can form the output or results of a function that is evaluating other data in the worksheet.

For example, the first argument of the IF function in row 4—the logical test argument—is required to return a Boolean value as an answer. The argument must always evaluate a condition that can only ever result in a TRUE or FALSE response. As a result:

  • If the argument returns an answer of TRUE, the function performs one action. In this example, it multiplies the data in cell A2 by 25.
  • If the argument returns an answer of FALSE, the function performs a different action. In this case, it multiplies the data in cell A2 by 10.

Boolean Values and Arithmetic Functions

Unlike logical functions, most functions in Excel and Google Sheets that perform arithmetic operations such as SUM, COUNT, and AVERAGE ignore Boolean values when they are in cells included in a function’s arguments.

For example, in the example image, the COUNT function in row 5, which only counts cells containing numbers, ignores the TRUE and FALSE Boolean values located in cells A3, A4, and A5 and returns an answer of 0.

Converting TRUE and FALSE to 1 and 0

To have Boolean values included in the calculations of arithmetic functions, you must first convert them to numeric values before passing them to the function. Two ways of accomplishing this step are to:

  • Multiply the Boolean values by one (as shown by the formulas in rows 7 and 8 of the example, which multiply the values TRUE and FALSE in cells A3 and A4 by one).
  • Add a zero to each Boolean value (as shown by the formula in row 9 of the example, which adds 0 to the value TRUE in cell A5).

These operations have the effect of converting the value TRUE in cells A3 and A5 to 1 and the value FALSE in cell A4 to 0. As a result, the COUNT function in row 10, which totals number data in cells A7 to A9, returns a result of 3 rather than 0.

Boolean Values and Excel Formulas

Unlike arithmetic functions, formulas in Excel and Google Sheets that carry out arithmetic operations such as addition and subtraction are happy to read Boolean values as numbers without the need for conversion. Such formulas automatically set TRUE equal to 1 and FALSE equal to 0.

As a result, the addition formula in row 6 in the example image,

= A3 + A4 + A5

reads the data in the three cells as:

= 1 + 0 + 1

and returns an answer of 2 accordingly.

Thanks for letting us know!

Get the Latest Tech News Delivered Every Day

Subscribe

Функции преобразования типов данных в VBA Excel. Наименования функций, синтаксис, типы возвращаемых данных, диапазоны допустимых значений выражения-аргумента.

Синтаксис функций преобразования

Выражение (аргумент) – это любое строковое или числовое выражение, возвращающее значение, входящее в диапазон допустимых значений для аргумента. Выражение может быть представлено переменной или другой функцией.

Если аргумент, переданный в функцию, не входит в диапазон типа, в который преобразуются данные, происходит ошибка.

Функции преобразования типов

Наименования функций преобразования типов, типы возвращаемых данных, диапазоны допустимых значений для аргумента:

Функция Тип данных Диапазон значений аргумента
CBool Boolean Любое допустимое строковое или числовое выражение.
CByte Byte От 0 до 255.
CCur Currency От -922 337 203 685 477,5808 до 922 337 203 685 477,5807.
CDate Date Любое допустимое выражение даты.
CDbl Double От -1,79769313486231E308 до -4,94065645841247E-324 для отрицательных значений; от 4,94065645841247E-324 до 1,79769313486232E308 для положительных значений.
CDec Decimal 79 228 162 514 264 337 593 543 950 335 для чисел без десятичных знаков. Для чисел с 28 десятичными знаками диапазон составляет 7,9228162514264337593543950335. Наименьшим возможным числом, отличным от нуля, является число 0,0000000000000000000000000001.
CInt Integer От -32 768 до 32 767, дробная часть округляется.
CLng Long От -2 147 483 648 до 2 147 483 647, дробная часть округляется.
CSng Single От -3,402823E38 до -1,401298E-45 для отрицательных значений; от 1,401298E-45 до 3,402823E38 для положительных значений.
CStr String Результат, возвращаемый функцией CStr, зависит от аргумента Выражение.
CVar Variant Диапазон совпадает с типом Double  для числовых значений и с типом  String  для нечисловых значений.

Дополнительно для VBA7:

Функция Тип данных Диапазон значений аргумента
CLngLng LongLong От -9 223 372 036 854 775 808 до 9 223 372 036 854 775 807, дробная часть округляется. Действительно только для 64-разрядных платформ.
CLngPtr LongPtr От -2 147 483 648 до 2 147 483 647 для 32-разрядных платформ, от -9 223 372 036 854 775 808 до 9 223 372 036 854 775 807 для 64-разрядных платформ, дробная часть округляется в обоих типах систем.

Примеры преобразования типов

Функция CBool

Функция CBool используется для преобразования выражений в тип данных Boolean.

Dim a

a = CBool(10) ‘Результат: True

a = CBool(0) ‘Результат: False

a = CBool(«True») ‘Результат: True

a = CBool(«Test») ‘Результат: Error

Dim a, b, c

a = «Test1»

b = «Test2»

c = CBool(a = b) ‘Результат: False

c = CBool(a <> b) ‘Результат: True

Функция CByte

Функция CByte используется для преобразования выражений в тип данных Byte.

Dim a, b, c

a = 654

b = 3.36

c = a / b ‘Результат: 194,642857142857

c = CByte(c) ‘Результат: 195

c = a * b ‘Результат: 2197,44

c = CByte(c) ‘Результат: Error

Функция CCur

Функция CCur используется для преобразования выражений в тип данных Currency.

Dim a, b, c

a = 254.6598254

b = 569.2156843

c = a + b ‘Результат: 823,8755097

c = CCur(a + b) ‘Результат: 823,8755

Функция CDate

Функция CDate используется для преобразования выражений в тип данных Date. Она распознает форматы даты в соответствии с национальной настройкой системы.

Dim a As String, b As Date, c As Double

a = «28.01.2021»

b = CDate(a) ‘Результат: #28.01.2021#

c = CDbl(b) ‘Результат: 44224

Dim a

a = CDate(44298.63895) ‘Результат: #12.04.2021 15:20:05#

a = CDate(44298) ‘Результат: #12.04.2021#

a = CDate(0.63895) ‘Результат: #15:20:05#

Функция CDbl

Функция CDbl используется для преобразования выражений в тип данных Double.

Dim a As String, b As String, c As Double

a = «45,3695423»

b = «548955,756»

c = CDbl(a) + CDbl(b) ‘Результат: 549001,1255423

Примечание
Eсли основной язык системы – русский, при записи в редакторе VBA Excel дробного числа в виде текста, ставим в качестве разделителя десятичных разрядов – запятую. Проверьте разделитель по умолчанию для своей национальной системы:
MsgBox Application.DecimalSeparator

Функция CDec

Функция CDec используется для преобразования выражений в тип данных Decimal.

Dim a As String, b As Double, c

a = «5,9228162514264337593543950335»

b = 5.92281625142643

c = CDec(a) CDec(b) ‘Результат: 0,0000000000000037593543950335

Dim a As Double, b As String, c

a = 4.2643E14

b = CStr(a) ‘Результат: «4,2643E-14»

c = CDec(a) ‘Результат: 0,000000000000042643

Функция CInt

Функция CInt используется для преобразования выражений в тип данных Integer.

Dim a As String, b As Integer

a = «2355,9228»

b = CInt(a) ‘Результат: 2356

Функция CLng

Функция CLng используется для преобразования выражений в тип данных Long.

Dim a As Date, b As Long

a = CDate(44298.63895) ‘Результат: #12.04.2021 15:20:05#

b = CLng(a) ‘Результат: 44299

a = CDate(b) ‘Результат: #13.04.2021#

Функция CSng

Функция CSng используется для преобразования выражений в тип данных Single.

Dim a As String, b As Single

a = «3,2365625106»

b = CSng(a) ‘Результат: 3,236562

Функция CStr

Функция CStr используется для преобразования выражений в тип данных String.

Dim a As Single, b As String

a = 5106.23

b = CStr(a) ‘Результат: «5106,23»

Функция CVar

Функция CVar используется для преобразования выражений в тип данных Variant.

Dim a As Double, b As String, c

a = 549258.232546

b = «Новое сообщение»

c = CVar(a) ‘Результат: 549258,232546 (Variant/Double)

c = CVar(b) ‘Результат: «Новое сообщение» (Variant/String)

Функции преобразования типов данных используются в тексте процедур VBA Excel для того, чтобы указать, что результатом выполнения той или иной операции должны стать данные определенного типа, отличающегося от типа, заданного по умолчанию.


Понравилась статья? Поделить с друзьями:
  • Books on word power
  • Books like say the word
  • Books for word formation
  • Books for word choice
  • Books about word formation