[Basic Tut] Download String

Posts 1–5 of 5 · Page 1 of 1
[Basic Tut] Download String

What?
This program will download a file (.txt or .php) from a FTP Server and put its content to use!

Why?
So you can check for updates, find peoples IP, get strings... Really anything that can be written down...

How?
Over the internet... You just need an FTP Server...
Just Google "Free FTP hosting" as outside links aren't allowed.

I want to make it check for updates!!!
You will need upload a .txt file to your FTP Server with the latest version written inside.
Example:
Code:
v1.0
I want only certain people to use my program!!!
A way you can do this is to get the IP's of the people that you want to use your program.
Create a .php file with the following code and host it on your server.
Code:
<?php echo $_SERVER['REMOTE_ADDR']; ?>
What do I do with Visual Basic???
Add 1 WebClient to your form.

Add this code to your project load page and it will check for updates. Alternatively you can add it to a button.
Code:
        If Not System.Text.Encoding.ASCII.GetString((WebClient1.DownloadData("http://yourfileurl.com/version.txt"))) = "v1.0" Then
            MsgBox("An update is availible")
        End If
Add this code to your project load page and it will only let people with certain IP's use the program.
Code:
        Dim UserIP As String = System.Text.Encoding.ASCII.GetString((WebClient1.DownloadData("http://yourfileurl.com/ip.php")))
        If UserIP = "IP1" Then
        ElseIf UserIP = "IP2" Then
        ElseIf UserIP = "IP3" Then
        ElseIf UserIP = "IP4" Then
        Else
            MsgBox("Your IP is not authorized to use this program" & vbNewLine & "The program will now close.", MsgBoxStyle.Exclamation, "Not Authorized!")
            End
        End If
If you need any help, just post below
If you would like to see some other features, PM me.
Good Tutorial. Thanks for sharing.
Do not use Goto Statement. Its a bad programming practice. Use Sub Procedures. Much better.
Waiting for more to come from you =)
Quote Originally Posted by Hassan View Post
Good Tutorial. Thanks for sharing.
Do not use Goto Statement. Its a bad programming practice. Use Sub Procedures. Much better.
Waiting for more to come from you =)
Thanks,
I was playing around with the GoTo but removed it, its not necessary...
Rather than this:
Code:
System.Text.Encoding.ASCII.GetString((WebClient1.DownloadData("http://yourfileurl.com/version.txt")))
You can simply use the DownloadString from the WebClient class instead to avoid the conversion manually.

Other than that, nice job!
Quote Originally Posted by Jason View Post
Rather than this:
Code:
System.Text.Encoding.ASCII.GetString((WebClient1.DownloadData("http://yourfileurl.com/version.txt")))
You can simply use the DownloadString from the WebClient class instead to avoid the conversion manually.

Other than that, nice job!
Right, this tut is still great and useful but the DownloadString is still easier

Thanks James.
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us