Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Property Setting Problem 1

Status
Not open for further replies.

PoppapumpJ

Programmer
Dec 17, 2001
86
US
Hey, I have a property that I want to store the network IP address in. I Would like to pass in the client's IP addres and truncate off the last ".XXX"

I put some formatting statements into the set area of the property but it keeps setting and returning the value passed in instead of my formatted value

it looks like this:

private mvarIPAddress as string

Public Property IpAddress() As String
Get
IpAddress = mvarIPAddress
End Get
Set(ByVal Value As String)
'Truncate Local IP to Network IP
Dim intLastDot As Integer
Dim intAmountToKeep As Integer
intLastDot = InStr(Value, ".")
intAmountToKeep += intLastDot
intLastDot = InStr(Right(Value, Len(Value) - intLastDot), ".")
intAmountToKeep += intLastDot
intLastDot = InStr(Right(Value, Len(Value) - intLastDot), ".")
intAmountToKeep += intLastDot
mvarIPAddress = Left(Value, intAmountToKeep + 1)
End Set
End Property
 
Try this it worked for me.

mvarIPAddress = Value.Remove(Value.LastIndexOf("."), (Value.Length - Value.LastIndexOf(".")))
That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Thanks, That worked perfectly!

.NET has all kinds of cool stuff like this that make things so much easier.
 
no problem. Yes .NET does have alot of cool stuff you just have to find it which can turn out to be a challenge sometimes.

Thx for the start J That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top