Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: I know that is out of TLUG but this is funny



--------------------------------------------------------
tlug note from "Jim Schweizer" <schweiz@example.com>
--------------------------------------------------------
Hi all,

On  3 Feb 97 at 11:43, Yuri Anissimov wrote:

> Hi all, something really puzzled me last night

This comes by way of my brother:

--------------------------------------------------------------

On to NULL values.  The NULL value in VB is, like all other correct
uses, is defined as being 'undefined'.  As a result you can not use it
directly in a comparison.  If you think about it, you can really asked
if 'undefined' is equal to anything or not.  However, there is VB
function 'isnull' that takes a VARIANT argument and returns TRUE if
the value is NULL and false if it is anything else.  The important
thing to remember is that a NULL value means that you do not know
anything at this time other than the existence of the property itself.

For example, you know that your next car is going to have a color but
you can not say what it is.  For me to ask 'is the color of your next
car = blue' you would respond by saying 'I don't know' or better still
'that is an invalid question'.  In a similar way, you can not ask if
the color your next car = unknown.  It really is equal to some color
and 'unknown' is not a color.  You can now see the problem with the
line of code 'If Not (qq = Null) Then'.  The correct formation of this
line is 'if not isnull(qq) then'.

The key to understanding this issue is the variable type called
VARIANT.
  A variant is variable that can have one of many different actual
  types
depending on its content.  The types include EMPTY, NULL, String,
integer, object reference, and so on and so on.....  The EMPTY value
means that the variant has not been set to anything yet.  There is a
support function 'isempty' that can check for this value.  The NULL
means that it has been set or looked at but the actual value is still
not know.  

There is some very serious math behind all this 'undefined' stuff. 
But, it is not important to understand all of this.  The key is to
understand that any operation performed on an undefined value is
itself undefined. There for you can not use 'undefined' or null 
directly.  If a comparison against undefined is itself undefined, then
'if undefined' itself is undefined and therefore makes no
sense....Welcome to the wonderful world of programming.
---------------------------------------------------------------------

Ouch,

regards,

Jim S.




> the only piece of code that is working:
> 
> if Null then ..
> 	else if Not Null then
> 		else ' Only here it is working ...
> 
> (calling routine has a variable of Null value, I am trying to pass it to
> subroutine:)
> 
> 
> Dim intNewCategory As Integer, intTruncateName As Integer, strTitle As
> String, intMsgDialog As Integer
> Dim stDocName As String
> 
> Dim qq As Variant
> Dim stLinkCriteria As String
>     stDocName = "Company"
>     strTitle = "Empty Code field"
> qq = Code.Value
> 
> If Not (qq = Null) Then
> Else
> intMsgDialog = vbYesNo + vbQuestion + vbDefaultButton1
>             intNewCategory = MsgBox("Do you want?", intMsgDialog, strTitle)
>             If intNewCategory = vbNo Then GoTo Exit_More_Click
>             qq = True
> End If
> 
> 
> Null is tranzitive according to Microsoft manual, but God Forbid...
> Yuri
> -----------------------------------------------------------------
> a word from the sponsor will appear below
> -----------------------------------------------------------------
> The TLUG mailing list is proudly sponsored by TWICS - Japan's First
> Public-Access Internet System.  Now offering 20,000 yen/year flat
> rate Internet access with no time charges.  Full line of corporate
> Internet and intranet products are available.   info@example.com
> Tel: 03-3351-5977   Fax: 03-3353-6096
> 
> 
------------------------------------------------------------
Jim Schweizer                           JPS Solutions
     http://www1.harenet.or.jp/~schweiz/
------------------------------------------------------------
-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links