VBA-Excel Convert string "FALSE" to "False"

This problem is driving me crazy! I have the following excel VBA code:

Sub Test()

Dim sTempVal As String

For i = 1 to 100
    sTempVal = ActiveSheet.Cells(i, 1).Value
    MsgBox sTempVal
Next i

As it overlaps the values ​​in the first column, if it encounters a FALSE value or a TRUE value, it automatically reads it as "False" or "True." Why does VBA automatically change business? I really need it to keep the exact case of this value in the cell. I thought in Dimning the sTempVal variable is like a string, it will just read the value in the cell and that’s it. Please note that this ONLY applies to FALSE and TRUE. Any other value will be read exactly as it appears in the cell.

+4
source share
2
Sub Test()

Dim sTempVal As String

For i = 1 to 100
    sTempVal = ActiveSheet.Cells(i, 1).Text
    MsgBox sTempVal
Next i

.Text: ", , , ".

EDIT # 1:

.Value, VBA , .

, :

=1=1

:

Sub WhatIsTruth()
    MsgBox ActiveCell.Value
End Sub

:

enter image description here

.Text .

+8

Range.Value a Variant, a String. String, .

...

sTempVal = ActiveSheet.Cells(i, 1).Value

... :

sTempVal = CStr(ActiveSheet.Cells(i, 1).Value)

VBA, Boolean String, - Excel . :

Debug.Print CStr(0 = 0) 'Prints "True"

, Excel , , Range.Text:

sTempVal = ActiveSheet.Cells(i, 1).Text
+4

Source: https://habr.com/ru/post/1656378/


All Articles