另一个VB问题 [英] Another VB question

查看:75
本文介绍了另一个VB问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试增强脚本以执行以下操作。


1)。检测段落的前四个单词并对其进行样式化

(已经这样做)

2)。大写和风格化每个段落的第一个字母(已经

通过样式表执行)

3)。计算段落的数量(或vbcrlf& vbcrfl的数量)所以

我可以在特定的地方插入图像(即我想动态地

插入图像第1段中的1,图2中的第2段,等等。)
第三项我无法弄清楚。我已经尝试了几种方法,但保持

遇到问题。


谢谢!!!


以下脚本由Mike Brind提供,感谢Mike。它目前可以产生我上面列出的前两个项目的结果,但是

并不完全按照我想要的方式。它将图像放入每个记录的第一个

段落中。但那不是我想要的。


Dim str,i,spacepos,word

for wank = 1 to 7

如果rsForums.EOF然后退出

如果wank = 1那么

response.write"< img id =''picFloat''src =''testoboy .jpg''

class =''picBorderThin''>"

结束如果

如果wank = 2那么

response.write"< img id =''picFloat''src =''me.jpg''

class =''picBorderThin''>"

结束如果

Response.Write"< p>< span id =''firstWords''>"

storyFix = replace( rsForums(" T_MESSAGE"),vbcrlf& vbcrlf,"< p>")

story = replace(storyFix,"< p>","< / p>"& vbcrlf&"< p>")

for i = 1 to 4

spacepos = instr(story,"" )

word = left(story,spacepos)

story = right(story,len(stor) y)-spacepos)

response.write word

next


Response.Write"< / span>"

Response.Write故事

Response.Write"< / p>" &安培; vbcrlf& vbcrlf& "< hr>"

rsForums.MoveNext

next

rsForums.Close

设置rsForums =没有什么

解决方案

"另一个约翰"写道......


for wank = 1 to 7

next



谈论耐力!!!


:oD


Rob


; - )

Rob Meade写道:


"另一个john"写道......


for wank = 1 to 7

next



谈论耐力!!!


:oD


Rob




其他john写道:


我正在尝试增强脚本来执行以下操作。


1)。检测段落的前四个单词并对其进行样式化

(已经这样做)

2)。大写和风格化每个段落的第一个字母(已经

通过样式表执行)

3)。计算段落的数量(或vbcrlf& vbcrfl的数量)所以

我可以在特定的地方插入图像(即我想动态地

插入图像第1段中的1,图2中的第2段,等等。)
第三项我无法弄清楚。我已经尝试了几种方法,但保持

遇到问题。


谢谢!!!


以下脚本由Mike Brind提供,感谢Mike。它目前可以产生我上面列出的前两个项目的结果,但是

并不完全按照我想要的方式。它将图像放入每个记录的第一个

段落中。但那不是我想要的。


Dim str,i,spacepos,word

for wank = 1 to 7

如果rsForums.EOF然后退出

如果wank = 1那么

response.write"< img id =''picFloat''src =''testoboy .jpg''

class =''picBorderThin''>"

结束如果

如果wank = 2那么

response.write"< img id =''picFloat''src =''me.jpg''

class =''picBorderThin''>"

结束如果

Response.Write"< p>< span id =''firstWords''>"

storyFix = replace( rsForums(" T_MESSAGE"),vbcrlf& vbcrlf,"< p>")

story = replace(storyFix,"< p>","< / p>"& vbcrlf&"< p>")

for i = 1 to 4

spacepos = instr(story,"" )

word = left(story,spacepos)

s tory = right(story,len(story)-spacepos)

response.write word

next


Response.Write" ;< / span>"

Response.Write故事

Response.Write"< / p>" &安培; vbcrlf& vbcrlf& "< hr>"

rsForums.MoveNext

next

rsForums.Close

设置rsForums =没有



我不会这样做...


在某个阶段,每个故事/文章都是进入数据库。它是在

指出我会以你想要的方式操纵它。这样,

操作只对每个故事执行一次,而不是每次请求页面时都是



Anyhoo,你需要在

中以相反的顺序解决问题。你需要做的第一件事就是把故事打成段落。无论是输入还是输出,都可以使用

split()来完成。你还需要把你的图像放到一个数组中,这样你就可以按索引获得



既然你有一个段落数组,那么图像数组,它是很容易从0到6循环,在每个段落前面加上

相关的图像html。在该循环中,您可以执行操作

来设置前几个单词的样式。您将创建一个包含

前7段的字符串(根据需要添加< ptags)。然后,如果剩下任何

段落,你需要循环遍历这些段落来设置

前几个单词的样式,然后将它们附加到你的字符串中。然后准备好输入/输出



-

Mike Brind


I''m trying to enhance a script to do the following things.

1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)

This third item I can''t figure out. I''ve tried it a few ways but keep
running to problems.

Thanks!!!

The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that''s not what I want.

Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id=''picFloat'' src=''testoboy.jpg''
class=''picBorderThin''>"
End if
if wank = 2 then
response.write "<img id=''picFloat'' src=''me.jpg''
class=''picBorderThin''>"
End if
Response.Write "<p><span id=''firstWords''>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next

Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing

解决方案

"the other john" wrote...

for wank = 1 to 7
next

Talk about stamina!!!

:oD

Rob


;-)
Rob Meade wrote:

"the other john" wrote...

for wank = 1 to 7
next


Talk about stamina!!!

:oD

Rob



the other john wrote:

I''m trying to enhance a script to do the following things.

1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)

This third item I can''t figure out. I''ve tried it a few ways but keep
running to problems.

Thanks!!!

The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that''s not what I want.

Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id=''picFloat'' src=''testoboy.jpg''
class=''picBorderThin''>"
End if
if wank = 2 then
response.write "<img id=''picFloat'' src=''me.jpg''
class=''picBorderThin''>"
End if
Response.Write "<p><span id=''firstWords''>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next

Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing

I wouldn''t do this like this...

At some stage, each story/article is entered into a database. It''s at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.

Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.

Now that you have an array of paragraphs, and an array of images, it''s
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.

--
Mike Brind


这篇关于另一个VB问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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