Hack Forums
[.NET] VB.Net ad system - 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] VB.Net ad system (/showthread.php?tid=4812041)



VB.Net ad system - titanbullet - May 8, 2015

Hello again 🤝 Today I am releasing my little ad system for vb.net applications, as a "thank you" to everyone who helped me in my previous thread (this one)

Drop a Picturebox, a timer and a progress bar, import system.Net and type Dim count as integer = 1 below public class Form1 at the top of your form.
Code
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
      Dim wb As New WebClient
      If adbar.Value = adbar.Maximum Then
      If Count = 3 Then
      If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad3.png") Then
      PictureBox1.Load(My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad3.png")
      Else
      PictureBox1.Load("http://voidblaze.esy.es/leaguehelper/ads/pics/ad3.png")
      PictureBox1.Refresh()
      wb.DownloadFileAsync(New Uri("http://voidblaze.esy.es/leaguehelper/ads/pics/ad3.png"), My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad3.png")
      End If
      adbar.Value = 0
      Count = 4
      End If
      If Count = 2 Then
      If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad3.png") Then
      PictureBox1.Load(My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad2.png")
      Else
      PictureBox1.Load("http://voidblaze.esy.es/leaguehelper/ads/pics/ad2.png")
      PictureBox1.Refresh()
      wb.DownloadFileAsync(New Uri("http://voidblaze.esy.es/leaguehelper/ads/pics/ad2.png"), My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad2.png")
      End If
      adbar.Value = 0
      Count = 3
      End If
      If Count = 1 Then
      If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad3.png") Then
      PictureBox1.Load(My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad1.png")
      Else
      PictureBox1.Load("http://voidblaze.esy.es/leaguehelper/ads/pics/ad1.png")
      PictureBox1.Refresh()
      wb.DownloadFileAsync(New Uri("http://voidblaze.esy.es/leaguehelper/ads/pics/ad1.png"), My.Computer.FileSystem.SpecialDirectories.Temp + "\Leaguehelper\ad1.png")
      End If
      adbar.Value = 0
      Count = 2
      End If
      If Count = 4 Then
      adbar.Value = 0
      Count = 1
      End If
      Else
      adbar.Value = adbar.Value + 1
      End If
    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
      Dim client As WebClient = New WebClient()
      If Count = 3 Then
      Dim reply As String = client.DownloadString("https://www.dropbox.com/s/h7w2b5pg4vgedxl/adlink1.txt?dl=1")
      Process.Start(reply)
      End If
      If Count = 2 Then
      Dim reply As String = client.DownloadString("https://www.dropbox.com/s/l0u45unev5gco0i/adlink2.txt?dl=1")
      Process.Start(reply)
      End If
      If Count = 1 Then
      Dim reply As String = client.DownloadString("https://www.dropbox.com/s/fv87pqpbmigly0c/adlink3.txt?dl=1")
      Process.Start(reply)
      End If
    End Sub

I left the links as-is so that you can test it easily.Be sure to edit them out!
This system cycles through 3 png, that are uploaded to your own server so you can change them without the need to update the whole program. Save for the links, but those are placed in your dropbox.

Also keep in mind, this system will be used at my soon-to-be-released program LeagueHelper (http://voidblaze.esy.es/leaguehelper)
If someone wants to buy the above program's whole source at a discount before i release it, then please PM me :)


* - Ninja - May 8, 2015

This ad system is nothing more then a picturebox with an image that is downloaded. But good job nonetheless...
This makes me wonder what that big application is that you talked about in your other thread.


* - titanbullet - May 8, 2015

(May 8, 2015 04:13 AM)Tyranitar Wrote:  This ad system is nothing more then a picturebox with an image that is downloaded. But good job nonetheless...

Exactly, I wanted it simple. There is no real need to make something more complicated, at least for the model I need it. I could add something like statistics if needed.


* - Minimal. - May 8, 2015

My-Namespace and a Timer, no need to keep reading...


* - titanbullet - May 8, 2015

(May 8, 2015 06:52 AM)Felix. Wrote:  My-Namespace and a Timer, no need to keep reading...

Well, it works. So where is the problem?


* - Ninja - May 8, 2015

(May 8, 2015 08:10 AM)titanbullet Wrote:  Well, it works. So where is the problem?

Code could have been shortened by a lot and written a lot cleaner. Not saying it is bad, but it is just a simple if statement and an image downloader. Not really worthy of a thread... If it is an accomplishment for you, then good job. Also, what is that big program you mentioned earlier?


* - nuk - May 8, 2015

I have a Ad-Control I made a while back that you can have/use if you really want? Either way, this isn't the best but it works for what YOU need it to do... and that's all that counts ;) Great job OP!


* - titanbullet - May 8, 2015

(May 8, 2015 08:30 AM)Tyranitar Wrote:  Code could have been shortened by a lot and written a lot cleaner. Not saying it is bad, but it is just a simple if statement and an image downloader. Not really worthy of a thread... If it is an accomplishment for you, then good job. Also, what is that big program you mentioned earlier?

Indeed, this is the prototype. And its an accomplishment because its the first time im working with pictureboxes and webrequests. You can check it out at my website, http://voidblaze.esy.es/leaguehelper


(May 8, 2015 09:13 AM)nuk Wrote:  I have a Ad-Control I made a while back that you can have/use if you really want? Either way, this isn't the best but it works for what YOU need it to do... and that's all that counts ;) Great job OP!

I would love that. Anything that is better than what i did is always welcome, as I will learn a lot. Thanks for your kind words!


* - Ninja - May 8, 2015

(May 8, 2015 09:33 AM)titanbullet Wrote:  Indeed, this is the prototype. And its an accomplishment because its the first time im working with pictureboxes and webrequests. You can check it out at my website, http://voidblaze.esy.es/leaguehelper



I would love that. Anything that is better than what i did is always welcome, as I will learn a lot. Thanks for your kind words!

Also I noticed you are not disposing of your webclients. You have them run in a timer so a lot of garbage will probably pile up, so make sure to dispose. Use the "Using ... End Using" block if necessary.


* - titanbullet - May 8, 2015

(May 8, 2015 10:22 AM)Tyranitar Wrote:  Also I noticed you are not disposing of your webclients. You have them run in a timer so a lot of garbage will probably pile up, so make sure to dispose. Use the "Using ... End Using" block if necessary.

Will add (y) thanks! 👍