Boolean 데이터 형식(Visual Basic)Boolean Data Type (Visual Basic)
또는 일 수 있는 값을 True
저장 False
합니다.Holds values that can be only True
or False
. 및 키워드 True
는 False
두 변수의 상태에 해당 합니다 Boolean
.The keywords True
and False
correspond to the two states of Boolean
variables.
설명Remarks
Boolean 데이터 형식 (Visual Basic) 을 사용 하 여 true/false, 예/아니요 또는 설정/해제와 같은 두 가지 상태 값을 포함 합니다.Use the Boolean Data Type (Visual Basic) to contain two-state values such as true/false, yes/no, or on/off.
Boolean
의 기본값은 False
입니다.The default value of Boolean
is False
.
Boolean
값은 숫자로 저장 되지 않으며 저장 된 값은 숫자와 동일 하지 않습니다.Boolean
values are not stored as numbers, and the stored values are not intended to be equivalent to numbers. 및에 대해 동일한 숫자 값을 사용 하는 코드를 작성 하면 안 됩니다 True
False
.You should never write code that relies on equivalent numeric values for True
and False
. 가능 하면 Boolean
변수의 사용을 디자인 된 논리 값으로 제한 해야 합니다.Whenever possible, you should restrict usage of Boolean
variables to the logical values for which they are designed.
형식 변환Type Conversions
Visual Basic 숫자 데이터 형식 값을로 변환 하 Boolean
는 경우 0은이 되 False
고 다른 모든 값은가 됩니다 True
.When Visual Basic converts numeric data type values to Boolean
, 0 becomes False
and all other values become True
. Visual Basic Boolean
에서 값을 숫자 형식으로 변환 하는 경우는 False
0이 되 고는 True
-1이 됩니다.When Visual Basic converts Boolean
values to numeric types, False
becomes 0 and True
becomes -1.
Boolean
값과 숫자 데이터 형식 간에 변환 하는 경우 .NET Framework 변환 메서드는 항상 Visual Basic 변환 키워드와 동일한 결과를 생성 하지 않는다는 점을 명심 해야 합니다.When you convert between Boolean
values and numeric data types, keep in mind that the .NET Framework conversion methods do not always produce the same results as the Visual Basic conversion keywords. Visual Basic 변환은 이전 버전과 호환 되는 동작을 유지 하기 때문입니다.This is because the Visual Basic conversion retains behavior compatible with previous versions. 자세한 내용은 데이터 형식 문제 해결의 "부울 형식이 숫자 형식으로 정확 하 게 변환 되지 않습니다."를 참조 하세요.For more information, see "Boolean Type Does Not Convert to Numeric Type Accurately" in Troubleshooting Data Types.
프로그래밍 팁Programming Tips
음수.Negative Numbers.
Boolean
는 숫자 형식이 아니므로 음수 값을 나타낼 수 없습니다.Boolean
is not a numeric type and cannot represent a negative value. 어떤 경우에는를 사용 하 여Boolean
숫자 값을 포함 하면 안 됩니다.In any case, you should not useBoolean
to hold numeric values.문자를 입력 합니다.Type Characters.
Boolean
에는 리터럴 형식 문자 또는 식별자 형식 문자가 없습니다.Boolean
has no literal type character or identifier type character.Framework 형식.Framework Type. .NET Framework에서 해당하는 형식은 System.Boolean 구조체입니다.The corresponding type in the .NET Framework is the System.Boolean structure.
예제Example
다음 예제에서 runningVB
는 Boolean
간단한 예/아니요 설정을 저장 하는 변수입니다.In the following example, runningVB
is a Boolean
variable, which stores a simple yes/no setting.
Dim runningVB As Boolean
' Check to see if program is running on Visual Basic engine.
If scriptEngine = "VB" Then
runningVB = True
End If