Hack Forums
[.NET] SkypeResolver - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] SkypeResolver (/showthread.php?tid=4423895)



SkypeResolver - mnjx - Aug 31, 2014

Hello Guys ✌,

Simple SkypeResolver

[Image: sy621Au.png]

What you need :

2x Textbox
1x Button

Source Code :
Code
Imports System.Net

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim SkypeResolver As New WebClient
        Dim IP As String = SkypeResolver.DownloadString("http://abrasivecraft.com/api.php?cmd=10&username=" + TextBox1.Text)
        TextBox2.Text = IP
    End Sub
End Class


-mnjx


* - +Haze - Aug 31, 2014

4 ways to improve this code.

1. You should always try and handle errors if they occur using Try Catch statements.
2. Also, it's a good practise to dispose webclient component when you're done using it. So using a using block.
3. And why not assign downloadedstring to textbox2.text straight away instead of making a variable called IP?
4. Add some data validation for textbox1.


* - ElementalTree - Sep 1, 2014

The website api isn't even working, always returns "IP Address Not Found"


* - mnjx - Sep 1, 2014

(Sep 1, 2014 06:01 AM)ElementalTree Wrote:  The website api isn't even working, always returns "IP Address Not Found"

Mhh i dont know for me its working fine 😶


* - CartWright64 - Sep 1, 2014

Really thanks bro very useful :D D

to short aiohdssoidjas

[warn]


* - Washi - Sep 1, 2014

(Aug 31, 2014 06:08 AM)+Haze Wrote:  4 ways to improve this code.

1. You should always try and handle errors if they occur using Try Catch statements.
2. Also, it's a good practise to dispose webclient component when you're done using it. So using a using block.
3. And why not assign downloadedstring to textbox2.text straight away instead of making a variable called IP?
4. Add some data validation for textbox1.

1. Uh not really. Preventing the error is in most cases better than catching.
2. True, but do you know why it is a good practice ?
3. I'd actually do it like he did as well. What's wrong with having a variable?
4. The only real validation I can think of is checking if it the text box is empty or not. Are there any more ?


* - shooterbret - Sep 2, 2014

(Sep 1, 2014 06:01 AM)ElementalTree Wrote:  The website api isn't even working, always returns "IP Address Not Found"

Iv been using thier api for a while and it seems to resolver "better" when there are less people on. for example midday sometimes it wouldnt work for me.


* - +Haze - Sep 2, 2014

(Sep 1, 2014 10:29 PM)TheUnknownProgrammer Wrote:  1. Uh not really. Preventing the error is in most cases better than catching.
2. True, but do you know why it is a good practice ?
3. I'd actually do it like he did as well. What's wrong with having a variable?
4. The only real validation I can think of is checking if it the text box is empty or not. Are there any more ?

1. Let's say the website happened to be offline, how is he going to prevent that in this case? That's why I think he should use a Try Catch statement.
2. I think it's because if its not disposed its still hanging around in the memory and that's not good. And also, in everyday life stuff its always good to throw away something when you've finished using it.
3. Nothing. It's mere preference, but its always good to shorten your code when and if you can. That doesn't mean shorter code is better, but if you can then you should.
4.Like Odus said, the range of the character length.