Booleans

C

cmdolcet69

I have setup a boolean based on the following conditions

Public STRData as string
Public BooleanRedFlag as boolean = False

If STRData = "" then
_BooleanRedFlag = TRue
end If

What should happen is that is the STRData string is returned with
nothing it should set my boolean flag.
When i add a break point and a watch to my code the STRData value
says its true.

What am I missing it should read "".
 
J

jdrott1

I have setup a boolean based on the following conditions

Public STRData as string
Public BooleanRedFlag as boolean = False

If STRData = "" then
_BooleanRedFlag = TRue
end If

What should happen is that is the STRData string is returned with
nothing it should set my boolean flag.
When i add a break point and a watch to my code the STRData  value
says its true.

What am I missing it should read "".

looks like you've set the "" = true
 
G

Gillard

you declare BooleanRedFlag
and you use _BooleanRedFlag

this is 2 differents variables
 
J

jdrott1

Yes how can i set it to be true if STRDAta = "" but i still need to
keep STRdata a string- Hide quoted text -

- Show quoted text -

whats the rest of the code and where are you putting the break point?
you have it correct there is something preceding it not correct.

Dim variable1 As String
Dim variable2 As Boolean = False
If variable1 = "" Then
variable2 = True
end if
 
C

cmdolcet69

whats the rest of the code and where are you putting the break point?
you have it correct there is something preceding it not correct.

Dim variable1 As String
Dim variable2 As Boolean = False
If variable1 = "" Then
variable2 = True
end if

Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
Dim iReadChars, iRc As Integer

' If Bytes2Read not specified uses Buffersize
If Bytes2Read = 0 Then Bytes2Read = miBufferSize
If mhRS = -1 Then
Throw New ApplicationException( _
"Please initialize and open port before using this
method")
Else

' Creates an event for overlapped operations
If meMode = Mode.Overlapped Then
pHandleOverlappedRead(Bytes2Read)
Else
' Non overlapped mode
ReDim mabtRxBuf(Bytes2Read - 1)
iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)


Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

If STRdata = Nothing Then
_BadResponse = True
Else
End If
end function



I declare my STRData as a global string and I declare my _BadResponse
as a global boolean = false

I set my breakpoint at the If STRdata = Nothing Then


Any help would be appreciated.
 
J

jdrott1

 Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
        Dim iReadChars, iRc As Integer

        ' If Bytes2Read not specified uses Buffersize
        If Bytes2Read = 0 Then Bytes2Read = miBufferSize
        If mhRS = -1 Then
            Throw New ApplicationException( _
                "Please initialize and open port before using this
method")
        Else

            ' Creates an event for overlapped operations
            If meMode = Mode.Overlapped Then
                pHandleOverlappedRead(Bytes2Read)
            Else
                ' Non overlapped mode
                ReDim mabtRxBuf(Bytes2Read - 1)
                iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)

                Dim enc As New System.Text.ASCIIEncoding
                STRdata = enc.GetString(mabtRxBuf)

                If STRdata = Nothing Then
                    _BadResponse = True
                Else
                End If
end function

I declare my STRData as a global string and I declare my _BadResponse
as a global boolean = false

I set my breakpoint at the   If STRdata = Nothing Then

Any help would be appreciated.- Hide quoted text -

- Show quoted text -

if you put the break point on "if strdata = nothing"

what does it say for you global _BadResponse? is it still set to
false?
are you checking the strdata in the global position for the return
value?
do you use the variable in any other functions that might return a
value before you hit the break point?
 
J

jdrott1

if you put the break point on "if strdata = nothing"

what does it say for you global _BadResponse?  is it still set to
false?
are you checking the strdata in the global position for the return
value?
do you use the variable in any other functions that might return a
value before you hit the break point?- Hide quoted text -

- Show quoted text -

you are setting the string equal to something here: Dim enc As New
System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
 
C

cmdolcet69

you are setting the string equal to something here: Dim enc As New
System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

Ok maybe the cause of the issue could be this line:
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

because when i look closely at the STRdata string it comes over =
"0.10[]" It should only read "0.10" could this [] be throwing
everything off???and if so how can I get this our of my STRdata
string.
 
J

James Hahn

I think possibly that the debugger is confusing you.

If you examine
STRdata = Nothing
or
STRdata=""
in the debugger it will indicate true or false. This refers to the
expression, which is either true or false depending on the current value of
STRdata..

If you examine
STRdata
then the debugger should indicate the value of the string.

cmdolcet69 said:
you are setting the string equal to something here: Dim enc As New
System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

Ok maybe the cause of the issue could be this line:
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

because when i look closely at the STRdata string it comes over =
"0.10[]" It should only read "0.10" could this [] be throwing
everything off???and if so how can I get this our of my STRdata
string.
 
J

Jack Jackson

Also note that STRdata = Nothing is True only if STRdata is Nothing.

STRdata = "" is True if STRdata is the empty string ("") or Nothing.

I think possibly that the debugger is confusing you.

If you examine
STRdata = Nothing
or
STRdata=""
in the debugger it will indicate true or false. This refers to the
expression, which is either true or false depending on the current value of
STRdata..

If you examine
STRdata
then the debugger should indicate the value of the string.

cmdolcet69 said:
On Aug 26, 2:33 pm, cmdolcet69 <[email protected]>
wrote:

I have setup a boolean based on the following conditions

Public STRData as string
Public BooleanRedFlag as boolean = False

If STRData = "" then
_BooleanRedFlag = TRue
end If

What should happen is that is the STRData string is returned
with
nothing it should set my boolean flag.
When i add a break point and a watch to my code the STRData
value
says its true.

What am I missing it should read "".

looks like you've set the "" = true

Yes how can i set it to be true if STRDAta = "" but i still need
to
keep STRdata a string- Hide quoted text -

- Show quoted text -

whats the rest of the code and where are you putting the break
point?
you have it correct there is something preceding it not correct.

Dim variable1 As String
Dim variable2 As Boolean = False
If variable1 = "" Then
variable2 = True
end if

Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
Dim iReadChars, iRc As Integer

' If Bytes2Read not specified uses Buffersize
If Bytes2Read = 0 Then Bytes2Read = miBufferSize
If mhRS = -1 Then
Throw New ApplicationException( _
"Please initialize and open port before using this
method")
Else

' Creates an event for overlapped operations
If meMode = Mode.Overlapped Then
pHandleOverlappedRead(Bytes2Read)
Else
' Non overlapped mode
ReDim mabtRxBuf(Bytes2Read - 1)
iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)

Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

If STRdata = Nothing Then
_BadResponse = True
Else
End If
end function

I declare my STRData as a global string and I declare my _BadResponse
as a global boolean = false

I set my breakpoint at the If STRdata = Nothing Then

Any help would be appreciated.- Hide quoted text -

- Show quoted text -

if you put the break point on "if strdata = nothing"

what does it say for you global _BadResponse? is it still set to
false?
are you checking the strdata in the global position for the return
value?
do you use the variable in any other functions that might return a
value before you hit the break point?- Hide quoted text -

- Show quoted text -

you are setting the string equal to something here: Dim enc As New
System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

Ok maybe the cause of the issue could be this line:
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

because when i look closely at the STRdata string it comes over =
"0.10[]" It should only read "0.10" could this [] be throwing
everything off???and if so how can I get this our of my STRdata
string.
 
C

cmdolcet69

Also note that STRdata = Nothing is True only if STRdata is Nothing.

STRdata = "" is True if STRdata is the empty string ("") or Nothing.

I think possibly that the debugger is confusing you.
If you examine
STRdata = Nothing
or
STRdata=""
in the debugger it will indicate true or false. This refers to the
expression, which is either true or false depending on the current value of
STRdata..
If you examine
STRdata
then the debugger should indicate the value of the string.
cmdolcet69 said:
On Aug 26, 2:33 pm, cmdolcet69 <[email protected]>
wrote:
I have setup a boolean based on the following conditions
Public STRData as string
Public BooleanRedFlag as boolean = False
If STRData = "" then
_BooleanRedFlag = TRue
end If
What should happen is that is the STRData string is returned
with
nothing it should set my boolean flag.
When i add a break point and a watch to my code the STRData
value
says its true.
What am I missing it should read "".
looks like you've set the "" = true
Yes how can i set it to be true if STRDAta = "" but i still need
to
keep STRdata a string- Hide quoted text -
- Show quoted text -
whats the rest of the code and where are you putting the break
point?
you have it correct there is something preceding it not correct.
Dim variable1 As String
Dim variable2 As Boolean = False
If variable1 = "" Then
variable2 = True
end if
Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
Dim iReadChars, iRc As Integer
' If Bytes2Read not specified uses Buffersize
If Bytes2Read = 0 Then Bytes2Read = miBufferSize
If mhRS = -1 Then
Throw New ApplicationException( _
"Please initialize and open port before using this
method")
Else
' Creates an event for overlapped operations
If meMode = Mode.Overlapped Then
pHandleOverlappedRead(Bytes2Read)
Else
' Non overlapped mode
ReDim mabtRxBuf(Bytes2Read - 1)
iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
If STRdata = Nothing Then
_BadResponse = True
Else
End If
end function
I declare my STRData as a global string and I declare my _BadResponse
as a global boolean = false
I set my breakpoint at the If STRdata = Nothing Then
Any help would be appreciated.- Hide quoted text -
- Show quoted text -
if you put the break point on "if strdata = nothing"
what does it say for you global _BadResponse? is it still set to
false?
are you checking the strdata in the global position for the return
value?
do you use the variable in any other functions that might return a
value before you hit the break point?- Hide quoted text -
- Show quoted text -
you are setting the string equal to something here: Dim enc As New
System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
Ok maybe the cause of the issue could be this line:
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
because when i look closely at the STRdata string it comes over =
"0.10[]" It should only read "0.10" could this [] be throwing
everything off???and if so how can I get this our of my STRdata
string.

I have used the following to try and get my condition to hit inside
the loop

If STRdata is string.empty then
BoolRedFlag = true
end if


If STRdata.lenght=0 then
BoolRedFlag = true
end if



if STRdata = "" then
BoolRedFlag = true
end if


Nothing will ever hit the BoolRedFlag even if the STRdata="" when i
highlight over the STRdata = it give me a value of True however if i
highlight over just the STRdata it will give me a value of "" which i
would think the above statements would catch and go into the loop.
 
C

cmdolcet69

I think possibly that the debugger is confusing you.

If you examine
STRdata = Nothing
or
STRdata=""
in the debugger it will indicate true or false. This refers to the
expression, which is either true or false depending on the current value of
STRdata..

If you examine
STRdata
then the debugger should indicate the value of the string.


Ok maybe the cause of the issue could be this line:
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
because when i look closely at the STRdata string it comes over =
"0.10[]" It should only read "0.10" could this [] be throwing
everything off???and if so how can I get this our of my STRdata
string.

You are correct in that saying however how can i get it into my
condition? It seems to skip over it each time?
 
J

Jack Jackson

Also note that STRdata = Nothing is True only if STRdata is Nothing.

STRdata = "" is True if STRdata is the empty string ("") or Nothing.

I think possibly that the debugger is confusing you.
If you examine
STRdata = Nothing
or
STRdata=""
in the debugger it will indicate true or false. This refers to the
expression, which is either true or false depending on the current value of
STRdata..
If you examine
STRdata
then the debugger should indicate the value of the string.
On Aug 26, 3:19 pm, jdrott1 <[email protected]> wrote:
On Aug 26, 3:03 pm, cmdolcet69 <[email protected]> wrote:
On Aug 26, 3:55 pm, jdrott1 <[email protected]> wrote:
On Aug 26, 2:42 pm, cmdolcet69 <[email protected]> wrote:
On Aug 26, 3:35 pm, jdrott1 <[email protected]> wrote:
On Aug 26, 2:33 pm, cmdolcet69 <[email protected]>
wrote:
I have setup a boolean based on the following conditions
Public STRData as string
Public BooleanRedFlag as boolean = False
If STRData = "" then
_BooleanRedFlag = TRue
end If
What should happen is that is the STRData string is returned
with
nothing it should set my boolean flag.
When i add a break point and a watch to my code the STRData
value
says its true.
What am I missing it should read "".
looks like you've set the "" = true
Yes how can i set it to be true if STRDAta = "" but i still need
to
keep STRdata a string- Hide quoted text -
- Show quoted text -
whats the rest of the code and where are you putting the break
point?
you have it correct there is something preceding it not correct.
Dim variable1 As String
Dim variable2 As Boolean = False
If variable1 = "" Then
variable2 = True
end if
Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
Dim iReadChars, iRc As Integer
' If Bytes2Read not specified uses Buffersize
If Bytes2Read = 0 Then Bytes2Read = miBufferSize
If mhRS = -1 Then
Throw New ApplicationException( _
"Please initialize and open port before using this
method")
Else
' Creates an event for overlapped operations
If meMode = Mode.Overlapped Then
pHandleOverlappedRead(Bytes2Read)
Else
' Non overlapped mode
ReDim mabtRxBuf(Bytes2Read - 1)
iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
If STRdata = Nothing Then
_BadResponse = True
Else
End If
end function
I declare my STRData as a global string and I declare my _BadResponse
as a global boolean = false
I set my breakpoint at the If STRdata = Nothing Then
Any help would be appreciated.- Hide quoted text -
- Show quoted text -
if you put the break point on "if strdata = nothing"
what does it say for you global _BadResponse? is it still set to
false?
are you checking the strdata in the global position for the return
value?
do you use the variable in any other functions that might return a
value before you hit the break point?- Hide quoted text -
- Show quoted text -
you are setting the string equal to something here: Dim enc As New
System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
Ok maybe the cause of the issue could be this line:
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
because when i look closely at the STRdata string it comes over =
"0.10[]" It should only read "0.10" could this [] be throwing
everything off???and if so how can I get this our of my STRdata
string.

I have used the following to try and get my condition to hit inside
the loop

If STRdata is string.empty then
BoolRedFlag = true
end if


If STRdata.lenght=0 then
BoolRedFlag = true
end if



if STRdata = "" then
BoolRedFlag = true
end if


Nothing will ever hit the BoolRedFlag even if the STRdata="" when i
highlight over the STRdata = it give me a value of True however if i
highlight over just the STRdata it will give me a value of "" which i
would think the above statements would catch and go into the loop.

The only test you should need is If STRdata = "". Put a breakpoint on
the If STRdata = "" line. When the code gets there step it.
 
J

James Hahn

Please refer to your other post. You may be seeing a string which consists
of non-ASCII characters. This string will not be equal to "" even if it
looks empty. When the debugger breaks use an expression such as
STRdata.Length or Asc(STRdata) to examine the string.

cmdolcet69 said:
I think possibly that the debugger is confusing you.

If you examine
STRdata = Nothing
or
STRdata=""
in the debugger it will indicate true or false. This refers to the
expression, which is either true or false depending on the current value
of
STRdata..

If you examine
STRdata
then the debugger should indicate the value of the string.


On Aug 26, 3:19 pm, jdrott1 <[email protected]> wrote:
On Aug 26, 3:03 pm, cmdolcet69 <[email protected]> wrote:
On Aug 26, 3:55 pm, jdrott1 <[email protected]> wrote:
On Aug 26, 2:42 pm, cmdolcet69 <[email protected]>
wrote:
On Aug 26, 3:35 pm, jdrott1 <[email protected]> wrote:
On Aug 26, 2:33 pm, cmdolcet69 <[email protected]>
wrote:
I have setup a boolean based on the following conditions
Public STRData as string
Public BooleanRedFlag as boolean = False
If STRData = "" then
_BooleanRedFlag = TRue
end If
What should happen is that is the STRData string is
returned
with
nothing it should set my boolean flag.
When i add a break point and a watch to my code the
STRData
value
says its true.
What am I missing it should read "".
looks like you've set the "" = true
Yes how can i set it to be true if STRDAta = "" but i still
need
to
keep STRdata a string- Hide quoted text -
- Show quoted text -
whats the rest of the code and where are you putting the break
point?
you have it correct there is something preceding it not correct.
Dim variable1 As String
Dim variable2 As Boolean = False
If variable1 = "" Then
variable2 = True
end if
Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
Dim iReadChars, iRc As Integer
' If Bytes2Read not specified uses Buffersize
If Bytes2Read = 0 Then Bytes2Read = miBufferSize
If mhRS = -1 Then
Throw New ApplicationException( _
"Please initialize and open port before using this
method")
Else
' Creates an event for overlapped operations
If meMode = Mode.Overlapped Then
pHandleOverlappedRead(Bytes2Read)
Else
' Non overlapped mode
ReDim mabtRxBuf(Bytes2Read - 1)
iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
If STRdata = Nothing Then
_BadResponse = True
Else
End If
end function
I declare my STRData as a global string and I declare my
_BadResponse
as a global boolean = false
I set my breakpoint at the If STRdata = Nothing Then
Any help would be appreciated.- Hide quoted text -
- Show quoted text -
if you put the break point on "if strdata = nothing"
what does it say for you global _BadResponse? is it still set to
false?
are you checking the strdata in the global position for the return
value?
do you use the variable in any other functions that might return a
value before you hit the break point?- Hide quoted text -
- Show quoted text -
you are setting the string equal to something here: Dim enc As New
System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
Ok maybe the cause of the issue could be this line:
Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
because when i look closely at the STRdata string it comes over =
"0.10[]" It should only read "0.10" could this [] be throwing
everything off???and if so how can I get this our of my STRdata
string.

You are correct in that saying however how can i get it into my
condition? It seems to skip over it each time?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top