Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > slide show in vb

Reply
Thread Tools

slide show in vb

 
 
Adam Sandler
Guest
Posts: n/a
 
      07-11-2006
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!

 
Reply With Quote
 
 
 
 
Nick Malik [Microsoft]
Guest
Posts: n/a
 
      07-11-2006
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/Sho...69916&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: ups.com...
> 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!
>



 
Reply With Quote
 
 
 
 
Adam Sandler
Guest
Posts: n/a
 
      07-11-2006
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/Sho...69916&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!

 
Reply With Quote
 
Nick Malik [Microsoft]
Guest
Posts: n/a
 
      07-11-2006
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: oups.com...
> 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/Sho...69916&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!
>



 
Reply With Quote
 
Adam Sandler
Guest
Posts: n/a
 
      07-11-2006

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!

 
Reply With Quote
 
Adam Sandler
Guest
Posts: n/a
 
      07-11-2006

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!

 
Reply With Quote
 
Nick Malik [Microsoft]
Guest
Posts: n/a
 
      07-12-2006
"Adam Sandler" <> wrote in message
news: oups.com...
>
> 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.
--


 
Reply With Quote
 
Adam Sandler
Guest
Posts: n/a
 
      07-26-2006

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[i] 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

 
Reply With Quote
 
Nick Malik [Microsoft]
Guest
Posts: n/a
 
      07-29-2006
"Adam Sandler" <> wrote in message
news: ups.com...
>
> 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[i] 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.
--


 
Reply With Quote
 
Adam Sandler
Guest
Posts: n/a
 
      07-31-2006

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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] Slide Show (S9) Gem V0.6 - New and Improved Support for UsingYour Own Slide Show Templates Gerald Bauer Ruby 0 08-26-2008 08:12 PM
get all word of slide through aspose.slide akshar108 via DotNetMonster.com ASP .Net 0 10-30-2007 04:49 AM
Slide-in & slide-out Scroller Help! banyan Javascript 0 11-16-2005 08:05 AM
Good slide scanning service vs. good slide scanner for Do-It-Yourself? LAshooter Digital Photography 0 06-25-2005 07:14 AM
How to build a slide show? =?Utf-8?B?UnVkeQ==?= ASP .Net 7 05-09-2005 07:05 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57