[VB.NET]GeoIP Using XML[Source] - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19) +---- Thread: [VB.NET]GeoIP Using XML[Source] (/showthread.php?tid=26647) Pages:
1
2
|
[VB.NET]GeoIP Using XML[Source] - Ch4ng3m3 - 06-27-2012 http://pastebin.com/U6zeRDTn RE: [VB.NET]GeoIP Using XML[Source] - 911Computer - 06-27-2012 thanks Ch4ng3m3 i was looking for this code. RE: [VB.NET]GeoIP Using XML[Source] - AceInfinity - 06-30-2012 I'm not clicking that adfly link for you. I'd be surprised to see if these 2 members are not one in the same. RE: [VB.NET]GeoIP Using XML[Source] - HF~Legend - 07-01-2012 Noob member... Adfly + adcrun for get the link pastebin ... WT* ? RE: [VB.NET]GeoIP Using XML[Source] - Ch4ng3m3 - 07-02-2012 complaint and complaint..?... mind your own business kid RE: [VB.NET]GeoIP Using XML[Source] - AceInfinity - 07-02-2012 (07-02-2012, 07:00 AM)Ch4ng3m3 Wrote: complaint and complaint..?... mind your own business kid 'kid' being non-plural for him or myself? Because judging by your profile age I am older than you. RE: [VB.NET]GeoIP Using XML[Source] - Ch4ng3m3 - 07-02-2012 (07-02-2012, 04:25 PM)AceInfinity Wrote: 'kid' being non-plural for him or myself? Because judging by your profile age I am older than you. ok fine RE: [VB.NET]GeoIP Using XML[Source] - AceInfinity - 07-02-2012 I haven't looked at the link yet, but if it's just source, then why not post it in a code tag? You're still a new member here, so your reputation in terms of trust among other things around here is still low. You're not going to gain respect here by posting your first 5 or so posts here as adfly links. RE: [VB.NET]GeoIP Using XML[Source] - Kewlz - 07-03-2012 Here's the code. Code: Imports System.Xml RE: [VB.NET]GeoIP Using XML[Source] - AceInfinity - 07-03-2012 The method you have here is practically useless unless somebody else has your exact setup, you could have simplified this much further as well, and used parameters (that's what they are there for, and this is a prime example of where it could be useful to have some). If you're going to release a source like this you should expect some feedback, whether it's good or bad. I would have also used a class for this, another prime example of where it could be useful. Maybe not in your mind for something so simple, although what if now you have a program that keeps track of multiple geolocations? You're going to do that all manually? What about multi-threading here? Code: For i = 0 To xmlnode.Count - 1 That would be the equivalent of For i = 0 To 0 here in this case lol Also you have a stray line here which doesn't do anything: Code: xmlnode(i).ChildNodes.Item(0).InnerText.Trim() Code: Dim i As Integer You don't have to do that here... If you want to loop through all nodes and childnodes of those nodes you'd do something like this: Code: For i As Integer = 0 To xmlnode.Count - 1 Otherwise, since we know here that there is only 1 xmlnode (xmlnode(0)), then we could avoid this loop entirely as we also know how many childnodes there is. It really doesn't do you any good to use a loop if you're going to write all of the values out manually like that anyways lol. So you'd be better off just not using the loop. If you want to use a loop though then you'd do what I suggested above. I would have done this like so: Code: Private Function GetGeoLocation(IP As String) As GEOLocation Now say we could return multiple GeoLocations for some reason from this website, then I would create a List(Of GEOLocation) and return that from the function for each iteration through the nodes after all childnodes have been looped through. But that's not the case, so perhaps a loop here is overkill. Regardless, there's still many anomalies in the code i've seen there... Not good. One last thing, don't ever name your variables with the names of existing Classes from the .NET namspaces you've referenced. VB is case-insensitive: Code: Dim xmlnode As XmlNodeList XmlNode is already a Class: http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.aspx The reason i'm using a class with properties there is for encapsulation of the Trim() method, you could create a function to do whatever you want with the input strings before setting the values in stone, so this was just a demonstration, I wouldn't repeat that though if it's anything more complicated than Trim(), create a function to do it and return a modified value if you want. |