Re: Differences between VB6 and VB.Net causing problem
- From: "Schmidt" <sss@xxxxxxxxx>
- Date: Tue, 21 Oct 2008 01:43:53 +0200
"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:OyJOFBpMJHA.3588@xxxxxxxxxxxxxxxxxxxxxxx
Suffice it to say, that in types other than Byte and String, -1
is the value stored when representing True.
To add some fun into the discussion... the above is 'True',
.... and just to formulate it a bit "stronger":
Dont force a boolean compare or Bit-Op, if you cannot
be sure that the Variable really contains 0 or -1.
The following snippet shows, that you cannot even rely
on the content of VBs Boolean-Variables, to be *always*
0 or -1.
It came up some years ago in the german groups - I only
readjusted the example a bit, to be more comprehensible,
covering a (more or less) "realistic" scenario...
Option Explicit
Private Sub Form_Load()
If AppInitializeNeeded Then 'we don't have files in the App.Path
'so we should initialize
Debug.Print "Really... no Files there?"
Else 'proceed normally with your App
End If
End Sub
Function AppInitializeNeeded() As Boolean
Dim boolFilesFound As Boolean 'we rely on the cast on this variable
FilesExistInPath App.Path, boolFilesFound
AppInitializeNeeded = Not boolFilesFound
'just to shade some light on VBs misbehaviour...
'the result of that statement is really "funny" ;-)
Debug.Print CInt(boolFilesFound);
End Function
Sub FilesExistInPath(Path As String, VReturn As Variant)
Dim FileCount As Long
'Determine the FileCount in a DirLoop for example -
'here we only simulate the result, stored in a Long
FileCount = 3
'now we pass the result back in the ByRef-Param
VReturn = FileCount
End Sub
Olaf
.
- Follow-Ups:
- Re: Differences between VB6 and VB.Net causing problem
- From: dpb
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- References:
- Differences between VB6 and VB.Net causing problem
- From: Howard G
- Re: Differences between VB6 and VB.Net causing problem
- From: Tom Shelton
- Re: Differences between VB6 and VB.Net causing problem
- From: expvb
- Re: Differences between VB6 and VB.Net causing problem
- From: Tom Shelton
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Bill McCarthy
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Re: Differences between VB6 and VB.Net causing problem
- From: Robert Morley
- Re: Differences between VB6 and VB.Net causing problem
- From: Larry Serflaten
- Differences between VB6 and VB.Net causing problem
- Prev by Date: Re: LargeHex function revisited
- Next by Date: Re: LargeHex function revisited
- Previous by thread: Re: Differences between VB6 and VB.Net causing problem
- Next by thread: Re: Differences between VB6 and VB.Net causing problem
- Index(es):
Relevant Pages
|
Loading