slide show in vb

Discussion in 'ASP .Net' started by Adam Sandler, Jul 11, 2006.

  1. Adam Sandler

    Adam Sandler Guest

    Hello,

    I'd like to do a slide show in VB. I have one in JavaScript but the
    one in JavaScript always counts on the images to be in a given
    directory. This doesn't have to be fancy... something like...
    Me.Image1.ImageUrl = myArray(i) and automatically repeating. The
    reasons for why I want to do it in VB follow.

    The images for this slideshow will be retrieved from links on a
    webpage. The code for this uses regular expressions to search for the
    files... the files conform to a standard naming scheme so any risk is
    minimized

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load

    CONST WEBPAGE =
    "http://www.srh.noaa.gov/ridge/RadarImg/N0R/FTG/"

    Dim objHTTP
    Dim strHTMLSource As String

    ' Get stuff from other webpage
    objHTTP = CreateObject("Microsoft.XMLHTTP")
    objHTTP.Open("Get", WEBPAGE, False)
    objHTTP.Send()

    ' Load the target webpage into memory... it's small
    strHTMLSource = objHTTP.ResponseText

    ' Look for files which begin with "FTG"
    myMatcher("FTG", strHTMLSource)

    End Sub

    ' myMatcher(what I'm looking for, where to search)
    Sub myMatcher(ByVal strMatchPattern, ByVal strSource)

    Dim i, j As Integer

    Dim myRegEx As Regex = New Regex(strMatchPattern,
    RegexOptions.IgnoreCase)
    Dim c As MatchCollection = myRegEx.Matches(strSource)

    i = 0

    ' iterate through the collection
    Dim m As Match
    For Each m In c
    ReDim Preserve myArray(i)
    myArray(i) = m.Index
    i = i + 1
    Next

    Dim s As String

    ' Get the most recent 10 file names...
    ' Accomplished by using the positions found by the pattern
    matcher
    For j = UBound(myArray) To (UBound(myArray) - 20) Step -1
    ' remainder division eliminates duplicate file names which
    would be sucked up
    ' from both the link's text and the a href tag
    If j Mod 2 = 0 Then
    s = Mid(strSource, myArray(j + 1), 26)
    Response.Write(s & "<br />") ' for debug...
    End If
    Next

    Once I get the files I'm interested in using, then I figured I could
    just loop through the array and provide an asp image object the url
    contained in anyArray(i).

    u = UBound(myArray)

    For i = 0 To (u - 1)
    Me.Image1.ImageUrl = myArray(i)
    System.Threading.Thread.Sleep(3000)
    Next

    Doing something like the preceeding loop doesn't work... I really don't
    want anymore complexity then something like the loop above and the
    images to automatically repeat. Any suggestions?

    Thanks!
     
    Adam Sandler, Jul 11, 2006
    #1
    1. Advertising

  2. Your code demonstrates a very practical (and somewhat procedural) approach
    to writing code. For you, I'd suggest that the easy answer is to throw in
    Application.DoEvents() after each assignment to ImageUrl.

    Here's a thread that discussed this issue not that long ago.
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=469916&SiteID=1

    Hope this helps,
    --
    --- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a
    programmer helping programmers.
    --
    "Adam Sandler" <> wrote in message
    news:...
    > Hello,
    >
    > I'd like to do a slide show in VB. I have one in JavaScript but the
    > one in JavaScript always counts on the images to be in a given
    > directory. This doesn't have to be fancy... something like...
    > Me.Image1.ImageUrl = myArray(i) and automatically repeating. The
    > reasons for why I want to do it in VB follow.
    >
    > The images for this slideshow will be retrieved from links on a
    > webpage. The code for this uses regular expressions to search for the
    > files... the files conform to a standard naming scheme so any risk is
    > minimized
    >
    > Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles Me.Load
    >
    > CONST WEBPAGE =
    > "http://www.srh.noaa.gov/ridge/RadarImg/N0R/FTG/"
    >
    > Dim objHTTP
    > Dim strHTMLSource As String
    >
    > ' Get stuff from other webpage
    > objHTTP = CreateObject("Microsoft.XMLHTTP")
    > objHTTP.Open("Get", WEBPAGE, False)
    > objHTTP.Send()
    >
    > ' Load the target webpage into memory... it's small
    > strHTMLSource = objHTTP.ResponseText
    >
    > ' Look for files which begin with "FTG"
    > myMatcher("FTG", strHTMLSource)
    >
    > End Sub
    >
    > ' myMatcher(what I'm looking for, where to search)
    > Sub myMatcher(ByVal strMatchPattern, ByVal strSource)
    >
    > Dim i, j As Integer
    >
    > Dim myRegEx As Regex = New Regex(strMatchPattern,
    > RegexOptions.IgnoreCase)
    > Dim c As MatchCollection = myRegEx.Matches(strSource)
    >
    > i = 0
    >
    > ' iterate through the collection
    > Dim m As Match
    > For Each m In c
    > ReDim Preserve myArray(i)
    > myArray(i) = m.Index
    > i = i + 1
    > Next
    >
    > Dim s As String
    >
    > ' Get the most recent 10 file names...
    > ' Accomplished by using the positions found by the pattern
    > matcher
    > For j = UBound(myArray) To (UBound(myArray) - 20) Step -1
    > ' remainder division eliminates duplicate file names which
    > would be sucked up
    > ' from both the link's text and the a href tag
    > If j Mod 2 = 0 Then
    > s = Mid(strSource, myArray(j + 1), 26)
    > Response.Write(s & "<br />") ' for debug...
    > End If
    > Next
    >
    > Once I get the files I'm interested in using, then I figured I could
    > just loop through the array and provide an asp image object the url
    > contained in anyArray(i).
    >
    > u = UBound(myArray)
    >
    > For i = 0 To (u - 1)
    > Me.Image1.ImageUrl = myArray(i)
    > System.Threading.Thread.Sleep(3000)
    > Next
    >
    > Doing something like the preceeding loop doesn't work... I really don't
    > want anymore complexity then something like the loop above and the
    > images to automatically repeat. Any suggestions?
    >
    > Thanks!
    >
     
    Nick Malik [Microsoft], Jul 11, 2006
    #2
    1. Advertising

  3. Adam Sandler

    Adam Sandler Guest

    Nick Malik [Microsoft] wrote:
    > For you, I'd suggest that the easy answer is to throw in
    > Application.DoEvents() after each assignment to ImageUrl.
    >
    > Here's a thread that discussed this issue not that long ago.
    > http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=469916&SiteID=1


    Nick,

    Thanks for the reply... I'm confused though. My post was about looping
    through paths to images which are contained in an array. I'm not sure
    what that has to do with refreshing a page.... could you please
    clarify?

    Thanks!
     
    Adam Sandler, Jul 11, 2006
    #3
  4. You posted code, including:

    > u = UBound(myArray)


    > For i = 0 To (u - 1)
    > Me.Image1.ImageUrl = myArray(i)
    > System.Threading.Thread.Sleep(3000)
    > Next


    > Doing something like the preceeding loop doesn't work


    There is no particular reason why this shouldn't work, except that you don't
    give the current thread time to actually get and display the image. So I'm
    asking you to try adding a DoEvents in the loop before the Thread.Sleep to
    see if that helps. I didn't run your code on my box to see if you got
    actual URLs in your array. I'm assuming you did.

    --
    --- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a
    programmer helping programmers.
    --
    "Adam Sandler" <> wrote in message
    news:...
    > Nick Malik [Microsoft] wrote:
    >> For you, I'd suggest that the easy answer is to throw in
    >> Application.DoEvents() after each assignment to ImageUrl.
    >>
    >> Here's a thread that discussed this issue not that long ago.
    >> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=469916&SiteID=1

    >
    > Nick,
    >
    > Thanks for the reply... I'm confused though. My post was about looping
    > through paths to images which are contained in an array. I'm not sure
    > what that has to do with refreshing a page.... could you please
    > clarify?
    >
    > Thanks!
    >
     
    Nick Malik [Microsoft], Jul 11, 2006
    #4
  5. Adam Sandler

    Adam Sandler Guest

    Nick Malik [Microsoft] wrote:
    > You posted code, including:
    >
    > > u = UBound(myArray)

    >
    > > For i = 0 To (u - 1)
    > > Me.Image1.ImageUrl = myArray(i)
    > > System.Threading.Thread.Sleep(3000)
    > > Next

    >
    > > Doing something like the preceeding loop doesn't work

    >
    > There is no particular reason why this shouldn't work


    Which is why I'm here ;) I just need a very simple way of rotating
    through a collection of images... no effects, nav buttons etc... just
    looping through my images.

    > So I'm asking you to try adding a DoEvents in the loop before the Thread.Sleep to
    > see if that helps.


    I was hoping there was a VB way to preload images. Kinda like in
    JavaScript so that mouseovers are not all jacked up when the page is
    first visited. Unfortunately, it cannot help... DoEvents is not a
    member of System.Web.HTTPApplicationState

    > I didn't run your code on my box to see if you got actual URLs in your array. I'm
    > assuming you did.


    Here's everything as a sanity check. I've hardcoded some paths until
    this gets working. Then I'll change it over to iterating through my
    array:

    Dim myArray() As String =
    {"http://csfdgis/Lightning/Images/DeleteMe/pic1.jpg", _

    "http://myServer/Lightning/Images/pic2.jpg", _

    "http://myServer/Lightning/Images/pic3.jpg", _

    "http://myServer/Lightning/Images/pic4.jpg", _

    "http://myServer/Lightning/Images/pic5.jpg"}

    Dim i, u As Integer

    u = UBound(myArray)

    For i = 0 To (u - 1)
    Me.Image1.ImageUrl = myArray(i)
    ' Application.DoEvents()
    System.Threading.Thread.Sleep(3000)
    Next


    Thanks again for your help thus far!
     
    Adam Sandler, Jul 11, 2006
    #5
  6. Adam Sandler

    Adam Sandler Guest

    Adam Sandler wrote:

    > Dim myArray() As String =
    > {"http://csfdgis/Lightning/Images/DeleteMe/pic1.jpg", _


    In the preceeding post, this line is in error... it was commented out.
    I removed the commented when I should have deleted the whole line
    before posting... Sorry, it's been a long day!
     
    Adam Sandler, Jul 11, 2006
    #6
  7. "Adam Sandler" <> wrote in message
    news:...
    >
    > Nick Malik [Microsoft] wrote:
    >> You posted code, including:

    <clip>
    >> So I'm asking you to try adding a DoEvents in the loop before the
    >> Thread.Sleep to
    >> see if that helps.

    >
    > I was hoping there was a VB way to preload images. Kinda like in
    > JavaScript so that mouseovers are not all jacked up when the page is
    > first visited. Unfortunately, it cannot help... DoEvents is not a
    > member of System.Web.HTTPApplicationState


    No. Doevents is not part of System.Web. It is
    System.Windows.Forms.Application.DoEvents()

    The code you wrote won't work in ASP.Net. Not even close. Is that what you
    are trying to do? You never mentioned that you were writing an ASP.Net app,
    so I assumed you were writing a VB rich client. Let me know if I've been
    barking up the wrong tree.

    --
    --- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a
    programmer helping programmers.
    --
     
    Nick Malik [Microsoft], Jul 12, 2006
    #7
  8. Adam Sandler

    Adam Sandler Guest

    Nick Malik [Microsoft] wrote:
    > You never mentioned that you were writing an ASP.Net app,
    > so I assumed you were writing a VB rich client.


    I apologize... I assumed I was in the aspnet newsgroup.

    As far as what I'm trying to do is find a VB way to make a simple
    slideshow... by taking a collection and iterating through it. Nothing
    more and nothing less.

    If that collection is an array of strings and each string is a URL,
    then I can throw array into the ImageUrl property a asp Image
    component.

    I already have something working in JavaScript. I'd like to convert it
    to VB (and that is where I'm havuing the obvious difficulty)...

    document.images.myImage.src = wxImages[imageCounter].src

    // go until the last images is reached and then reset(start
    over)
    if (imageCounter < wxImages.length - 1)
    imageCounter++
    else
    imageCounter = 0
     
    Adam Sandler, Jul 26, 2006
    #8
  9. "Adam Sandler" <> wrote in message
    news:...
    >
    > Nick Malik [Microsoft] wrote:
    >> You never mentioned that you were writing an ASP.Net app,
    >> so I assumed you were writing a VB rich client.

    >
    > I apologize... I assumed I was in the aspnet newsgroup.


    My bad. I answer questions in different groups. Please forgive.

    >
    > As far as what I'm trying to do is find a VB way to make a simple
    > slideshow... by taking a collection and iterating through it. Nothing
    > more and nothing less.


    From a web client, it makes more sense to do this client side using
    Javascript. Feeding it from the server doesn't make sense in the stateless
    web model.

    >
    > If that collection is an array of strings and each string is a URL,
    > then I can throw array into the ImageUrl property a asp Image
    > component.


    And why would your client come back to the server to get the new image?
    Once it has an image, it's done. You'd need to put code into the client
    telling it to come back for the next image. Then, on the server side,
    simply keep state and move an array index for each call. Doesn't make
    sense, though. Better to have the client "aware" of the list of images and
    to iterate from there.

    >
    > I already have something working in JavaScript.


    stop there. you are done.

    > I'd like to convert it
    > to VB (and that is where I'm havuing the obvious difficulty)...


    because it is a bad idea, unless there are requirements that you have not
    shared that make it worth doing.


    Sorry I couldn't help you to achieve this idea.

    --
    --- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a
    programmer helping programmers.
    --
     
    Nick Malik [Microsoft], Jul 29, 2006
    #9
  10. Adam Sandler

    Adam Sandler Guest

    Nick Malik [Microsoft] wrote:
    > From a web client, it makes more sense to do this client side using
    > Javascript. Feeding it from the server doesn't make sense in the stateless
    > web model.


    My goal is indeed to have the client side do the processing... sorry
    for any confusion.

    > And why would your client come back to the server to get the new image?


    The client isn't going back to the server... it's going to an external
    website. The list of images I'm getting is created on the client side
    and the images themselves update every four minutes. So I have to
    account for different file names because they have a time stamp as a
    part of the file name. I find the file names I need via some regular
    expression code I wrote.

    > Once it has an image, it's done. You'd need to put code into the client
    > telling it to come back for the next image.


    Which I already have -- I put the regular expression method in the
    page_load to build my array with the list of maching file names.

    > Better to have the client "aware" of the list of images and
    > to iterate from there.


    I thought I was doing that -- everything is on the client side; please
    let me know where I put server side code in so I can correct it.

    > stop there. you are done.
    >
    > because it is a bad idea, unless there are requirements that you have not
    > shared that make it worth doing.


    The reason why I'd like to convert the simple JavaScript slideshow
    (posted previously) is that my matcher and array are in VB (the regular
    expression stuff I mentioned above).

    So unless there's a way to pass VB as a parameter to a JavaScript
    argument, I'd prefer to convert my JavaScript example to VB. I have no
    freaking clue how I would even attempt to use something which simulates
    regular expressions in JavaScript and searching the web hasn't been
    fruitful.

    As far as the reason why some of my code is in VB and some in
    JavaScript. I'm trying merging things I've done on other projects
    which worked well by themselves into working together on my latest
    task.

    Thanks for the help thus far!
     
    Adam Sandler, Jul 31, 2006
    #10
  11. I am sorry for my confusion. You've got me confused again. VB in the
    ASP.NET environment ONLY runs on a server. It never runs on a client. The
    only way that VB.Net runs on a client is in a rich client environment
    (windows app or click-once app).

    Of course, VBScript runs in IE, if that's what you are doing, but I don't
    think it is. I don't think you have regular expressions in VBScript.

    Here's what I _think_ you want:

    User requests a page. HTML page downloads. This includes Javascript. The
    Javascript immediately calls back to the server for data.
    Server code executes: The server code figures out the list of URLs you want.
    The server code is written in VB.Net and runs in the ASP.Net
    environment.
    The server code returns a list of URLs in JSON or XML format.
    Client code receives the data and stores it in a data island or an array.
    Whatever you are comfortable using.
    Client code runs a timer in Javascript. Gets the next image using the list
    of URLs returned by the server.

    This is called the AJAX model, but Microsoft provides controls under the
    moniker of Atlas. See http://atlas.asp.net for detailed information on
    these controls and on the Ajax programming model using ASP.Net

    I hope this helps.

    --
    --- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a
    programmer helping programmers.
    --
     
    Nick Malik [Microsoft], Aug 1, 2006
    #11
  12. Adam Sandler

    Adam Sandler Guest

    Nick Malik [Microsoft] wrote:
    > See http://atlas.asp.net for detailed information on
    > these controls and on the Ajax programming model using ASP.Net
    >
    > I hope this helps.


    It does... I was wondering if I would have to go down the AJAX road.
    Sorry for the confusion... I'm getting fed a lot of new stuff all at
    once and not being very elegant about it -- add AJAX to the list now!
    At any rate, thanks for your patience and assistance!
     
    Adam Sandler, Aug 1, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnVkeQ==?=

    How to build a slide show?

    =?Utf-8?B?UnVkeQ==?=, May 5, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    532
    Brian Cryer
    May 9, 2005
  2. =?Utf-8?B?UnVkeQ==?=

    Slide show and Sql

    =?Utf-8?B?UnVkeQ==?=, May 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    580
    Lucas Tam
    May 10, 2005
  3. akshar108 via DotNetMonster.com

    get all word of slide through aspose.slide

    akshar108 via DotNetMonster.com, Oct 30, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    615
    akshar108 via DotNetMonster.com
    Oct 30, 2007
  4. Gerald Bauer
    Replies:
    0
    Views:
    280
    Gerald Bauer
    Aug 26, 2008
  5. banyan

    Slide-in & slide-out Scroller Help!

    banyan, Nov 16, 2005, in forum: Javascript
    Replies:
    0
    Views:
    133
    banyan
    Nov 16, 2005
Loading...

Share This Page