Using the "IsNothing" keyword - InfoPath Dev
in

InfoPath Dev

Using the "IsNothing" keyword

Last post 02-16-2007 12:07 PM by DuneBug. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-14-2007 09:25 AM

    • snufse
    • Not Ranked
    • Joined on 02-01-2007
    • USA
    • Posts 12

    Using the "IsNothing" keyword

    I my code behind I am using the "IsNothing" keyword and it gives an error: "Name "IsnNothing" is not declared". Is this not supported by InfoPath through the programming interface????

    If Not IsNothing(MyDataSet) Then
    If MyDataSet.Tables("Table").Rows.Count > 0 Then
    myNav.SelectSingleNode("//my:name", Me.NamespaceManager). _
    SetValue(MyDataSet.Tables("Table").Rows(0).Item(1))
    myNav.SelectSingleNode("//my:department", Me.NamespaceManager). _
    SetValue(MyDataSet.Tables("Table").Rows(0).Item(22))
    End If
    End If
  • 02-14-2007 10:44 AM In reply to

    Re: Using the "IsNothing" keyword

    Hi Rolf,
    What is "IsNothing"? Is this a built in function in VB.NET? If it is, it should be supported because InfoPath is .NET compatible.
    Patrick Halstead
    Project Manager at Qdabra
  • 02-15-2007 06:42 AM In reply to

    • snufse
    • Not Ranked
    • Joined on 02-01-2007
    • USA
    • Posts 12

    Re: Using the "IsNothing" keyword

    I have a windows app (code below) and works fine. In InfoPath 2007 gives me syntax error??????

    If Not IsNothing(MyDataSet) Then
    If MyDataSet.Tables("Table").Rows.Count > 0 Then
    TextBox1.Text = MyDataSet.Tables("Table").Rows(0).Item(1)
    TextBox2.Text = MyDataSet.Tables("Table").Rows(0).Item(22)
    End If
    End If


    Also from MSDN Help

    IsNothing returns True if the expression represents an object variable that currently has no object assigned to it; otherwise, it returns False.

    IsNothing is intended to work on reference types. A value type cannot hold a value of Nothing and reverts to its default value if you assign Nothing to it. If you supply a value type in Expression, IsNothing always returns False.


    Example
    The following example uses the IsNothing function to determine if an object variable is associated with any object instance.

    Visual Basic Copy Code
    Dim testVar As Object
    ' No instance has been assigned to variable testVar yet.
    Dim testCheck As Boolean
    ' The following call returns True.
    testCheck = IsNothing(testVar)
    ' Assign a string instance to variable testVar.
    testVar = "ABCDEF"
    ' The following call returns False.
    testCheck = IsNothing(testVar)
    ' Disassociate variable testVar from any instance.
    testVar = Nothing
    ' The following call returns True.
    testCheck = IsNothing(testVar)


  • 02-16-2007 12:58 AM In reply to

    Re: Using the "IsNothing" keyword

    Hi Rolf,
    Sorry, but I don't know. Could be something to do with the limitations of the dataset. InfoPath supports them, but there are limitations. I don't have confidence that it is a dataset issue, though.
    Patrick Halstead
    Project Manager at Qdabra
  • 02-16-2007 05:30 AM In reply to

    • snufse
    • Not Ranked
    • Joined on 02-01-2007
    • USA
    • Posts 12

    Re: Using the "IsNothing" keyword

    Patrick:

    Is there a way to ask Microsoft? Do you have a reference site I could use? Thanks.
  • 02-16-2007 12:07 PM In reply to

    • DuneBug
    • Not Ranked
    • Joined on 12-14-2006
    • USA
    • Posts 6

    Re: Using the "IsNothing" keyword

    I don't know what coding interface you are using (VB.net or the built-in infopath script.
    you might try this:

    dim obj as object

    if not obj is nothing then
    ' do blah
    end if

    "Is" is the comparison operator for reference types. Using it is the same thing as saying "if obj = nothing" except since obj and nothing are both reference types the "=" and "<>" operators won't work.

    Give it a shot, I hope it works. If it doesn't oh well, i gave it the old college try.
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.