(adsbygoogle = window.adsbygoogle || []).push({});
Hello,
Recently I've gotten back into coding with Visual basics as I've been making my own Notepad program. And I've been working on a code that I've finally finished, and decided to share with everyone. Of course, I give credit to the people who helped me fix some bugs with this code. Please make sure you have these requirements:
Requirements:
- Visual Basics 2008
- FTP Host to upload website files
Once you have Visual Basics 2008 opened, add a button then change the
TEXT,
not the name, to: Check for updates - Now once that is done, double click on the button. Then once you come the button's coding page, add this code to it:
Button1.Enabled = False
Button1.Text() = "Checking"
Label1.Text() = "Checking for updates"
WebClient1.DownloadFileAsync(New Uri("https://[B][COLOR="red"]WEBSITELINKHERE[/COLOR][/B]/version.txt"), "version.txt")
Now, once that is done add a label. Make sure it's name is Label1, you can always use a different label as long as you have the right name of the object in the code. After you've done that, go back to the code you added on the button. Change the WEBSITELINKHERE to your website link. Now, after you've done all that stuff right click inside your ToolBox and click:
Chose items...
After clicking that, you'll see a huge list of items in the .NET Framework Components tab. Look for the item that says WebClient. You can easily go to it by clicking "W" which will take you to the items that start with the letter W. Find WebClient, check it, and then click OK. Once you've clicked OK, go back to your ToolBox and find the item you added, which is WebClient. After finding it, add it.
Then once you see that it's added (It'll be listed below your Design Screen, where the Timer is also put.) click it once, and then on your very right you'll see a properties box. Near the top of that box, you'll see an icon that looks like Yellow lighting. Click it, and look for
DownloadFileCompleted. It's usually the second one listed. Then double click that.
Add this code:
Dim read As String = My.Computer.FileSystem.ReadAllText("version.txt")
Button1.Text = "Finished"
If Not read = "1.00" Then
If read = "" Then
Label1.Text = "Currently no updates available."
Else
Label1.Text = " " & read & " "
End If
End If
I'm adding screenshots in a little bit, but please give me feedback on this tutorial!
Other
If you want to make the button pop-up again after they click check for updates, simply edit the DownloadFileCompleted code to this:
Dim read As String = My.Computer.FileSystem.ReadAllText("version.txt")
Button1.Enabled = True
Button1.Text = "Check Again"
Dim read As String = My.Computer.FileSystem.ReadAllText("version.txt")
If Not read = "1.00" Then
If read = "" Then
Label1.Text = "Currently no updates available."
Else
Label1.Text = " " & read & " "
End If
End If
After you have done everything you've wanted, and your ready to notify the users of an update. Open up notepad, or my notepad program, and type in the text you want to have. Maybe a link to the new download, or where to check for the update. Then save that file as
version.txt, make sure it's a text file! Then go to your FTP Manager/File Manager, and upload that .txt file. You can always go back to change it. Since you use a WebClient, it goes off reading the webfiles, and what-ever you change it to will be what it displays. No-matter what, even if people don't have the latest verison of your program, once they click "Check for updates," it'll read what you have on your website. (H)