幻灯片放映在vb中 [英] slide show in vb

查看:80
本文介绍了幻灯片放映在vb中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我想在VB中进行幻灯片放映。我在JavaScript中有一个,但是JavaScript中的

总是依赖于给定

目录中的图像。这不一定是花哨的...类似......

Me.Image1.ImageUrl = myArray(i)并自动重复。

为什么我想在VB中这样做的原因如下。


此幻灯片的图片将从
$的链接中检索到b $ b网页。这个代码使用正则表达式来搜索

文件...这些文件符合标准命名方案所以任何风险都是最小化的b / b


受保护的子Page_Load(ByVal发送者为对象,ByVal e As

System.EventArgs)处理Me.Load


CONST WEBPAGE =

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


Dim objHTTP

Dim strHTMLSource As String


''从其他网页获取内容

objHTTP = CreateObject(" Microsoft.XMLHTTP")

objHTTP.Open(" Get",WEBPAGE,False)

objHTTP.Send()


''将目标网页加载到内存中。 ..它很小

strHTMLSource = objHTTP.ResponseText


''寻找以FTG开头的文件

myMatcher(" FTG",strHTMLSource)

结束子


''myMatcher(我在看什么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

''遍历收藏品

Dim m As Match

For Each m In c

ReDim保留myArray(i)

myArray(i)= m.Index

i = i + 1

下一页


Dim s As String


''获取最新的10个文件名......

''通过使用模式找到的位置完成

匹配器

对于j = UBound(myArray)To(UBound(myArray) - 20)Step -1

''余数除法消除了重复的文件名,

将从链接的文本和a href标签中被吸出

'' br />
如果j Mod 2 = 0则

s = Mid(strSource,myArray(j + 1),26)

Response.Write(s& "< br />")''用于调试...

结束如果

下一页


一次我得到了我有兴趣使用的文件,然后我想我可以

只是遍历数组并提供一个asp图像对象url

包含在anyArray中( i)。


u = UBound(myArray)


For i = 0 To(u - 1)

Me.Image1.ImageUrl = myArray(i)

System.Threading.Thread.Sleep(3000)

下一页


做像前面的循环之类的东西不起作用......我真的不想要b $ b想要更复杂的东西,比如上面的循环和

图像自动重复。有什么建议吗?


谢谢!

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!

推荐答案

你的代码演示了一个非常实用的(和有点程序性的方法

来编写代码。对于你,我建议简单的答案是在每次分配给ImageUrl之后输入

Application.DoEvents()。


这里''不久前讨论过这个问题的一个帖子。
http://forums.microsoft.com/MSDN/Sho...69916&SiteID=1

希望这会有所帮助,

-

--- Nick Malik [微软]

MCSD,CFPS,认证Scrummaster
http://blogs.msdn.com/nickmalik


免责声明:意见表达于这个论坛是我自己的,而不是我雇主的b $ b代表。

我不代表我的雇主回答问题。我只是一个帮助程序员的
程序员。

-

" Adam Sandler" < co **** @ excite.comwrote in message

news:11 ********************* @ b28g2000cwb.googlegro ups .com ...
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" <co****@excite.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...

您好,


我想在VB中进行幻灯片放映。我在JavaScript中有一个,但是JavaScript中的

总是依赖于给定

目录中的图像。这不一定是花哨的...类似......

Me.Image1.ImageUrl = myArray(i)并自动重复。

为什么我想在VB中这样做的原因如下。


此幻灯片的图片将从
$的链接中检索到b $ b网页。这个代码使用正则表达式来搜索

文件...这些文件符合标准命名方案所以任何风险都是最小化的b / b


受保护的子Page_Load(ByVal发送者为对象,ByVal e As

System.EventArgs)处理Me.Load


CONST WEBPAGE =

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


Dim objHTTP

Dim strHTMLSource As String


''从其他网页获取内容

objHTTP = CreateObject(" Microsoft.XMLHTTP")

objHTTP.Open(" Get",WEBPAGE,False)

objHTTP.Send()


''将目标网页加载到内存中。 ..它很小

strHTMLSource = objHTTP.ResponseText


''寻找以FTG开头的文件

myMatcher(" FTG",strHTMLSource)


End Sub


''myMatcher(我在找什么,在哪里搜索)

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


''迭代收集

Dim m As Match

每个m in c

ReDim保留myArray(i)

myArray(i)= m.Index

i = i + 1

下一页


Dim s As String


''获取最新的10个文件名...

''使用模式找到的位置完成

matcher

对于j = UBound(myArray)To(UBound(myArray) - 20)步骤-1

''余数除去了重复的文件名,

将从链接'的文本和一个href标签中获取

''

如果j Mod 2 = 0那么

s = Mid(strSource,myArray(j + 1),26)

Response.Write(s& "< br />")''用于调试...

结束如果

下一页


一次我得到了我有兴趣使用的文件,然后我想我可以

只是遍历数组并提供一个asp图像对象url

包含在anyArray中( i)。


u = UBound(myArray)


For i = 0 To(u - 1)

Me.Image1.ImageUrl = myArray(i)

System.Threading.Thread.Sleep(3000)

下一页


做像前面的循环之类的东西不起作用......我真的不想要b $ b想要更复杂的东西,比如上面的循环和

图像自动重复。有什么建议吗?


谢谢!
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 [微软]写道:
Nick Malik [Microsoft] wrote:

对于你,我建议简单的答案是在每次分配给ImageUrl之后输入

Application.DoEvents()。 />

这是一个不久前讨论过这个问题的线程。
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!


您发布了代码,包括:
You posted code, including:

u = UBound(myArray)
u = UBound(myArray)


For i = 0 To(u - 1)

Me.Image1.ImageUrl = myArray(i)

System.Threading.Thread.Sleep(3000)

下一个
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



没有特别的理由说明为什么这不起作用,除了你没有
给当前线程时间实际获取并显示图像。所以我是

要求你尝试在Thread.Sleep之前在循环中添加一个DoEvent,以便

看看是否有帮助。我没有在我的盒子上运行你的代码,看看你的数组中是否有实际的URL。我假设你做了。


-

--- Nick Malik [微软]

MCSD,CFPS,认证Scrummaster
http://blogs.msdn.com/nickmalik


免责声明:本论坛中表达的观点是我自己的,而不是我雇主的b $ b代表。

我不回答问题代表我的雇主。我只是一个帮助程序员的
程序员。

-

" Adam Sandler" < co **** @ excite.comwrote in message

news:11 ********************** @ s13g2000cwa.googlegr oups.com ...

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" <co****@excite.comwrote in message
news:11**********************@s13g2000cwa.googlegr oups.com...


Nick Malik [微软]写道:
Nick Malik [Microsoft] wrote:

>对你而言,我建议简单的答案是在每次分配到ImageUrl之后输入Application.DoEvents()。

这是一个不久前讨论过这个问题的线程。
http:// forums。 microsoft.com/MSDN/Sho...69916&SiteID=1



Nick,


感谢您的回复。 ..虽然我很困惑。我的帖子是关于通过包含在数组中的图像的路径来循环

。我不确定

与刷新页面有什么关系....你能否请

澄清?


谢谢!


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!



这篇关于幻灯片放映在vb中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆