4 Replies - 1327 Views - Last Post: 26 November 2012 - 05:20 AM Rate Topic: -----

#1 curum0  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 26-November 12

Need help - Creating a dynamic banner in simple VB.Net application

Posted 26 November 2012 - 02:52 AM

Hi all,

I am trying to add a banner to a simple VB.Net application.
By banner I mean that I have a folder with several jpeg files (I named them 1.jpeg,2.jpeg etc) and once the form is loaded I want them to rotate in the picturebox (or whatever tool is used) after lets say 5 or 10 second...
Could you advise how this can be done?

Many thanks.
Is This A Good Question/Topic? 1
  • +

Replies To: Need help - Creating a dynamic banner in simple VB.Net application

#2 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 20-September 12

Re: Need help - Creating a dynamic banner in simple VB.Net application

Posted 26 November 2012 - 03:29 AM

Hi,

Try this.

Step I : Create an array of string. Place paths of your images in each variable. Say
Path[0]= "D:\1.jpg"
Path[1]= "D:\2.jpg"
Path[2]= "D:\3.jpg"


Create another variable Count of Integer type
Dim Count as Integer=0



Step II: Create and integer variable say CaptTime.
On FromLoad event,
 CaptTime=DateAndTime.Now.Seconds 


Step III : Drag a Timer Control on the form. And on Timer1.Tick event Add following code. Create another integer variable called ElapsedTime.
ElapsedTime=DateAndTime.Now.Seconds-CaptTime
If(ElapsedTime=5) Then
if Not(Count>3) Then
Count= Count+1
End If
Picturebox1.Image= Path[Count]
CaptTime=DateAndTime.Now.Seconds




Hope this may work. The code written need not to be correct (Since I do not have visual studio currently) but idea is correct. Hope this was useful for you.
Was This Post Helpful? 1
  • +
  • -

#3 curum0  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 26-November 12

Re: Need help - Creating a dynamic banner in simple VB.Net application

Posted 26 November 2012 - 04:06 AM

Thank you very much!

The syntaxis is my big problem ((


 Picturebox.Image= Path[Count] 


throws me an error "String cannot be converted to System.Drawing.Image"
Was This Post Helpful? 0
  • +
  • -

#4 curum0  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 26-November 12

Re: Need help - Creating a dynamic banner in simple VB.Net application

Posted 26 November 2012 - 04:13 AM

I used
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim ElapsedTime As Integer
        Dim Count As Integer = 0
        Dim path(50) As String

        path(0) = "C:\photos\1.jpeg"
        path(1) = "C:\photos\2.jpeg"
        path(2) = "C:\photos\3.jpeg"


        ElapsedTime = DateAndTime.Now.Second - CaptTime

        If (ElapsedTime = 5) Then

            If Not (Count > 3) Then

                Count = Count + 1

            End If
        End If
        Picturebox.Image = Image.FromFile(path(Count))

        CaptTime = DateAndTime.Now.Second

    End Sub 


but when I run the program,nothing happens, picturebox shows nothing
Was This Post Helpful? 0
  • +
  • -

#5 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 20-September 12

Re: Need help - Creating a dynamic banner in simple VB.Net application

Posted 26 November 2012 - 05:20 AM

Sorry my mistake. Use, PictureBox1.ImageLocation=Path[i].ToString.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1