idea for a app. banner rotator w/ automatic Internet updates

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
12 posts Page 1 of 2
Contributors
User avatar
NewGuy
New Member
New Member
Posts: 20
Joined: Sat Jun 04, 2011 8:46 am

Hey there

i have been trying to figure out how to implement a banner system in my VB apps ... something like whats in MSN or other simular apps. - but with no success

the idea is that it should be dynamic .. and self updateable

I was playing with the idea that the app. was "born" with ex. 5 banners .. and when the app. was started up, it would test to see there was internet access .. and if there was.. it would go to a website ex:

http://www.myhomepage.com/banners

and download the banners from that homepage .. and start to display them in the app.

on the homepage there would be a range of banners, witch i would have given a number, ex. between 1 to 200

if no internet is present .. it just shows the banners that it was born with .. or the latest banners it dowloaded last time there was internet

and of cource in the VB app .. there also needs to be implemented a banner rotator/presentation

any ideas/suggestions for a super banner system ? :) ... i love VB and still in the starting pit
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Hello NewGuy,

I think the quickest way would be to add a webbrowser control to your form and point it to your banner page URL (get a simple javascript banner rotation script and add it to the page).

Or a webrequest to read the page source then grab the images/links and maybe use a timer to loop through the banners and display them in a picturebox.

How are you currently doing it?
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
NewGuy
New Member
New Member
Posts: 20
Joined: Sat Jun 04, 2011 8:46 am

Hi .. and thanks for a quick answer

i was thinking about the webbrowser control too .... i have been playing with that .. but i found a few things that makes webbrowser control maybe not the best way to go in my opinion :-)
1) Takes more resources
2) Looks a bit clumsy - and i guess it won't even display images if the feature is turned off in IE ?
3) Slow

the idea was not to show banners directly from the homepage - but to show the local included banner files .. maybe in a picture control ? .. and then download/add new banners, if new ones are available on the webpage

this way i rule out the nessesity to be on internet

the download of new banners should be "hidden" from the end user

i dont have much actual code right now, sorry ... just getting to know this awsome program :-) keeps me up at night ;)
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

You can make a text file, and add a direct link to a banner on each new line, and then you can use a timer to loop through them, each 2 minutes, display the next banner from next new line, using picturebox1.imagelocation = link

I can make a fast example for you.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
NewGuy
New Member
New Member
Posts: 20
Joined: Sat Jun 04, 2011 8:46 am

ahhh ok .... yeah ... a text file .. cool idea

thank you ... i would love to see a example of that ... seems like a easy way to go for a novice like me :)
User avatar
Zulf
Serious Programmer
Serious Programmer
Posts: 441
Joined: Fri Jun 11, 2010 7:46 am

Download text file.
Read url.
Go to url.
Download banner.
Show banner.

You can also use this for auto-updating:

Download text file.
Read file version.
Check if file version is greater than app version.
If result is yes:
Download new files (exe, dll, images, etc..)
If result is no:
Ignore.
Image
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

I'll make a DLL for you check back on this post later, I'll edit and post the attachment .
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Why don't you just make functions instead of dlls or whatever? Much easier to use and much more "pro" if you will
http://vagex.com/?ref=25000
User avatar
NewGuy
New Member
New Member
Posts: 20
Joined: Sat Jun 04, 2011 8:46 am

Axel wrote:
Why don't you just make functions instead of dlls or whatever? Much easier to use and much more "pro" if you will
i am open for suggestions .. i have no pref ... could you maybe be so kind as to give a example of this ?

thank you !
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

You could use this:
Code: Select all
    Dim imageList As String()

    Sub refreshBanners()

        Dim wc As WebClient = New WebClient()
        Dim banners As List(Of Image) = New List(Of Image)

        For i As Integer = 0 To imageList.Length - 1 'downloads and stores the images in memory
            Dim imagebytes As Byte()
            Try
                imagebytes = wc.DownloadData(imageList(i))
            Catch ex As Exception
                MsgBox("Error downloading banner " & imageList(i) & ": " & ex.Message)
                Continue For
            End Try

            Dim ms As MemoryStream = New MemoryStream(imagebytes)

            Dim img As Image
            Try
                img = Image.FromStream(ms)
            Catch ex As Exception
                MsgBox("Error getting image from " & imageList(i))
                Continue For
            Finally
                ms.Close()
            End Try

            picBanner.Image = img
            banners.Add(img)

            Thread.Sleep(10000) 'starting delay per banner
        Next

        If banners.Count = 0 Then Return

        While True 'loops through downloaded images

            For i As Integer = 0 To banners.Count - 1
                picBanner.Image = banners(i)
                Thread.Sleep(10000) 'delay per banner
            Next
        End While
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim wc As WebClient = New WebClient()
        imageList = wc.DownloadString("http://localhost/banners.txt").Split(vbCr)
        For i As Integer = 0 To imageList.Length - 1
            imageList(i) = imageList(i).Replace(vbLf, "")
        Next

        Dim t As Thread = New Thread(AddressOf refreshBanners)
        t.IsBackground = True
        t.Start()
    End Sub
Where banners.txt could be something like this:
Code: Select all
http://localhost/banners/banner1.png
http://localhost/banners/banner2.png
Last edited by mandai on Sun Jun 05, 2011 3:42 pm, edited 1 time in total.
12 posts Page 1 of 2
Return to “Tutorial Requests”