By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

GET SUBNET LOCATION IN VB.NET

P: n/a
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 ActiveDirectorySubnet
SubnetLocation = instance.Location
Console.WriteLine("SubnetLocation: " & SubnetLocation)
End Get

Set(ByVal value As String)
Dim instance As ActiveDirectorySubnet
instance.Location = SubnetLocation
End Set
End Property

Regards

Morten Fagermoen

Oct 29 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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 ActiveDirectorySubnet(arguments)

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...orysubnet.aspx

-----
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.activedirectorysubnet.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 ActiveDirectorySubnet
SubnetLocation = instance.Location
Console.WriteLine("SubnetLocation: " & SubnetLocation)
End Get
Set(ByVal value As String)
Dim instance As ActiveDirectorySubnet
instance.Location = SubnetLocation
End Set
End Property
Regards

Morten Fagermoen

Oct 29 '06 #2

P: n/a
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" <in*****@invalid.com.invalidwrote in message
news:e3*************************@newsgroups.comcas t.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 ActiveDirectorySubnet(arguments)

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...orysubnet.aspx

-----
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.activedirectorysubnet.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 ActiveDirectorySubnet
SubnetLocation = instance.Location
Console.WriteLine("SubnetLocation: " & SubnetLocation)
End Get
Set(ByVal value As String)
Dim instance As ActiveDirectorySubnet
instance.Location = SubnetLocation
End Set
End Property
Regards

Morten Fagermoen

Oct 30 '06 #3

P: n/a
I'm not an ActiveDirectory programmer, but it seems that the subnet is just
a standard TCP/IP subnet. The ActiveDirectorySubnet() method is looking for
a string subnet, so you would pass it "255.255.255.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" <in*****@invalid.com.invalidwrote in message
news:e3*************************@newsgroups.comcas t.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 ActiveDirectorySubnet(arguments)

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.activedirectorysubnet.activedirector ysubnet.aspx

-----
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.activedirectorysubnet.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 ActiveDirectorySubnet
SubnetLocation = instance.Location
Console.WriteLine("SubnetLocation: " & SubnetLocation)
End Get
Set(ByVal value As String)
Dim instance As ActiveDirectorySubnet
instance.Location = SubnetLocation
End Set
End Property
Regards
Morten Fagermoen

Oct 30 '06 #4

P: n/a
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" <in*****@invalid.com.invalidwrote in message
news:e3*************************@newsgroups.comcas t.net...
I'm not an ActiveDirectory programmer, but it seems that the subnet is
just a standard TCP/IP subnet. The ActiveDirectorySubnet() method is
looking for a string subnet, so you would pass it "255.255.255.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" <in*****@invalid.com.invalidwrote in message
news:e3*************************@newsgroups.comca st.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 ActiveDirectorySubnet(arguments)

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.activedirectorysubnet.activedirecto rysubnet.aspx

-----
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.activedirectorysubnet.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 ActiveDirectorySubnet
SubnetLocation = instance.Location
Console.WriteLine("SubnetLocation: " & SubnetLocation)
End Get
Set(ByVal value As String)
Dim instance As ActiveDirectorySubnet
instance.Location = SubnetLocation
End Set
End Property
Regards
Morten Fagermoen

Oct 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.