GET SUBNET LOCATION IN VB.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Morten Fagermoen

    GET SUBNET LOCATION IN VB.NET

    Hi!

    I try to get the subnet location info using the code below found at
    http://msdn2.microsoft.com/en-us/lib....location.aspx.
    But it only tells me that "instance" is used before it has been assigned a
    value. Can anyone tell me what to do to get my subnet location info?

    Public Property SubnetLocation( ) As String
    Get
    Dim instance As ActiveDirectory Subnet
    SubnetLocation = instance.Locati on
    Console.WriteLi ne("SubnetLocat ion: " & SubnetLocation)
    End Get

    Set(ByVal value As String)
    Dim instance As ActiveDirectory Subnet
    instance.Locati on = SubnetLocation
    End Set
    End Property



    Regards

    Morten Fagermoen



  • Tim Patrick

    #2
    Re: GET SUBNET LOCATION IN VB.NET

    You haven't yet created an instance of the "instance" variable, you've only
    defined a place where a true instance can reside. You need to declare it
    like this.

    Dim instance As New ActiveDirectory Subnet(argument s)

    where "arguments" are those values used to initialize the object. It requires
    an active directory context, a subnet name, and an optional site name. Here
    is the web page for the constructors.



    -----
    Tim Patrick
    Start-to-Finish Visual Basic 2005
    Hi!
    >
    I try to get the subnet location info using the code below found at
    >
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

    vedirectory.act ivedirectorysub net.location.as px.
    >
    But it only tells me that "instance" is used before it has been
    assigned a
    >
    value. Can anyone tell me what to do to get my subnet location info?
    >
    Public Property SubnetLocation( ) As String
    Get
    Dim instance As ActiveDirectory Subnet
    SubnetLocation = instance.Locati on
    Console.WriteLi ne("SubnetLocat ion: " & SubnetLocation)
    End Get
    Set(ByVal value As String)
    Dim instance As ActiveDirectory Subnet
    instance.Locati on = SubnetLocation
    End Set
    End Property
    Regards
    >
    Morten Fagermoen
    >

    Comment

    • Morten Fagermoen

      #3
      Re: GET SUBNET LOCATION IN VB.NET

      Thanks, that takes it one step further.

      I should get the subnet location for the computer that runs the program. Do
      you have an example, for a newbie, on how to write that?

      Regards

      Morten Fagermoen


      "Tim Patrick" <invalid@invali d.com.invalidwr ote in message
      news:e3b4697610 7c8c8c97b8e15ab e0@newsgroups.c omcast.net...
      You haven't yet created an instance of the "instance" variable, you've
      only defined a place where a true instance can reside. You need to declare
      it like this.
      >
      Dim instance As New ActiveDirectory Subnet(argument s)
      >
      where "arguments" are those values used to initialize the object. It
      requires an active directory context, a subnet name, and an optional site
      name. Here is the web page for the constructors.
      >

      >
      -----
      Tim Patrick
      Start-to-Finish Visual Basic 2005
      >
      >Hi!
      >>
      >I try to get the subnet location info using the code below found at
      >>
      >http://msdn2.microsoft.com/en-us/lib...yservices.acti
      >vedirectory.ac tivedirectorysu bnet.location.a spx.
      >>
      >But it only tells me that "instance" is used before it has been
      >assigned a
      >>
      >value. Can anyone tell me what to do to get my subnet location info?
      >>
      >Public Property SubnetLocation( ) As String
      >Get
      >Dim instance As ActiveDirectory Subnet
      >SubnetLocati on = instance.Locati on
      >Console.WriteL ine("SubnetLoca tion: " & SubnetLocation)
      >End Get
      >Set(ByVal value As String)
      >Dim instance As ActiveDirectory Subnet
      >instance.Locat ion = SubnetLocation
      >End Set
      >End Property
      >Regards
      >>
      >Morten Fagermoen
      >>
      >
      >

      Comment

      • Tim Patrick

        #4
        Re: GET SUBNET LOCATION IN VB.NET

        I'm not an ActiveDirectory programmer, but it seems that the subnet is just
        a standard TCP/IP subnet. The ActiveDirectory Subnet() method is looking for
        a string subnet, so you would pass it "255.255.25 5.0" or whatever subnet
        applies in your case.

        It wasn't clear from your original question whether you simply made a typo,
        or if you really weren't clear on what an instance of an object was. If it
        is the latter, I highly recommend that you spend some time learning the basics
        of .NET programming in Visual Basic, as instances and objects are pretty
        much the central idea of .NET programming. If it was just an oversight or
        a typo, then please forgive my forwardness in making this assumption.

        -----
        Tim Patrick
        Start-to-Finish Visual Basic 2005
        Thanks, that takes it one step further.
        >
        I should get the subnet location for the computer that runs the
        program. Do you have an example, for a newbie, on how to write that?
        >
        Regards
        >
        Morten Fagermoen
        >
        "Tim Patrick" <invalid@invali d.com.invalidwr ote in message
        news:e3b4697610 7c8c8c97b8e15ab e0@newsgroups.c omcast.net...
        >
        >You haven't yet created an instance of the "instance" variable,
        >you've only defined a place where a true instance can reside. You
        >need to declare it like this.
        >>
        >Dim instance As New ActiveDirectory Subnet(argument s)
        >>
        >where "arguments" are those values used to initialize the object. It
        >requires an active directory context, a subnet name, and an optional
        >site name. Here is the web page for the constructors.
        >>
        >http://msdn2.microsoft.com/en-us/lib...ryservices.act
        >ivedirectory.a ctivedirectorys ubnet.activedir ectorysubnet.as px
        >>
        >-----
        >Tim Patrick
        >Start-to-Finish Visual Basic 2005
        >>Hi!
        >>>
        >>I try to get the subnet location info using the code below found at
        >>>
        >>http://msdn2.microsoft.com/en-us/lib...oryservices.ac
        >>ti vedirectory.act ivedirectorysub net.location.as px.
        >>>
        >>But it only tells me that "instance" is used before it has been
        >>assigned a
        >>>
        >>value. Can anyone tell me what to do to get my subnet location
        >>info?
        >>>
        >>Public Property SubnetLocation( ) As String
        >>Get
        >>Dim instance As ActiveDirectory Subnet
        >>SubnetLocatio n = instance.Locati on
        >>Console.Write Line("SubnetLoc ation: " & SubnetLocation)
        >>End Get
        >>Set(ByVal value As String)
        >>Dim instance As ActiveDirectory Subnet
        >>instance.Loca tion = SubnetLocation
        >>End Set
        >>End Property
        >>Regards
        >>Morten Fagermoen
        >>>

        Comment

        • Morten Fagermoen

          #5
          Re: GET SUBNET LOCATION IN VB.NET

          Thanks again, you are not on the wrong direction when assuming that I
          haven't understood all of the basics yet. But it's getting better every
          day, thanks to people like you answering stupid questions.

          Once again, thank you for your help!!

          Morten



          "Tim Patrick" <invalid@invali d.com.invalidwr ote in message
          news:e3b4697610 bc8c8ca1128444f d8@newsgroups.c omcast.net...
          I'm not an ActiveDirectory programmer, but it seems that the subnet is
          just a standard TCP/IP subnet. The ActiveDirectory Subnet() method is
          looking for a string subnet, so you would pass it "255.255.25 5.0" or
          whatever subnet applies in your case.
          >
          It wasn't clear from your original question whether you simply made a
          typo, or if you really weren't clear on what an instance of an object was.
          If it is the latter, I highly recommend that you spend some time learning
          the basics of .NET programming in Visual Basic, as instances and objects
          are pretty much the central idea of .NET programming. If it was just an
          oversight or a typo, then please forgive my forwardness in making this
          assumption.
          >
          -----
          Tim Patrick
          Start-to-Finish Visual Basic 2005
          >
          >Thanks, that takes it one step further.
          >>
          >I should get the subnet location for the computer that runs the
          >program. Do you have an example, for a newbie, on how to write that?
          >>
          >Regards
          >>
          >Morten Fagermoen
          >>
          >"Tim Patrick" <invalid@invali d.com.invalidwr ote in message
          >news:e3b469761 07c8c8c97b8e15a be0@newsgroups. comcast.net...
          >>
          >>You haven't yet created an instance of the "instance" variable,
          >>you've only defined a place where a true instance can reside. You
          >>need to declare it like this.
          >>>
          >>Dim instance As New ActiveDirectory Subnet(argument s)
          >>>
          >>where "arguments" are those values used to initialize the object. It
          >>requires an active directory context, a subnet name, and an optional
          >>site name. Here is the web page for the constructors.
          >>>
          >>http://msdn2.microsoft.com/en-us/lib...ryservices.act
          >>ivedirectory. activedirectory subnet.activedi rectorysubnet.a spx
          >>>
          >>-----
          >>Tim Patrick
          >>Start-to-Finish Visual Basic 2005
          >>>Hi!
          >>>>
          >>>I try to get the subnet location info using the code below found at
          >>>>
          >>>http://msdn2.microsoft.com/en-us/lib...oryservices.ac
          >>>ti vedirectory.act ivedirectorysub net.location.as px.
          >>>>
          >>>But it only tells me that "instance" is used before it has been
          >>>assigned a
          >>>>
          >>>value. Can anyone tell me what to do to get my subnet location
          >>>info?
          >>>>
          >>>Public Property SubnetLocation( ) As String
          >>>Get
          >>>Dim instance As ActiveDirectory Subnet
          >>>SubnetLocati on = instance.Locati on
          >>>Console.Writ eLine("SubnetLo cation: " & SubnetLocation)
          >>>End Get
          >>>Set(ByVal value As String)
          >>>Dim instance As ActiveDirectory Subnet
          >>>instance.Loc ation = SubnetLocation
          >>>End Set
          >>>End Property
          >>>Regards
          >>>Morten Fagermoen
          >>>>
          >
          >

          Comment

          Working...