数据库结果 - 激活备注字段中的链接 [英] Database results - activating links within memo fields

查看:70
本文介绍了数据库结果 - 激活备注字段中的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我网站的用户向我们的数据库提交文章时

http://www.netterweb.com/articles/ )他们几乎总是在文本中有http://

地址。他们将该文本粘贴到一个框中,该框将

保存到备忘录字段中。当通过网页上的结果显示时,链接是非活动的,除非用户知道足够在

文本中使用html。但是,我的大多数用户并不精通HTML。有没有办法我可以用
代码该字段的结果来制作任何文本中的活动链接

前面有http:// ?


先谢谢你的帮助。


Mike

When users of my site submit articles to our database
(http://www.netterweb.com/articles/) they almost always have http://
addresses within the text. They are pasting that text into a box which saves
to a memo field. When displayed through results on a webpage, the links are
inactive, unless the user was knowledgable enough to use html within the
text. However, most of my users are not html savvy. Is there a way I can
code the results of that field to make an active link out of any text
preceeded by "http://" ?

Thanks in advance for your help.

Mike

推荐答案

magmike写道:
magmike wrote:
当我的网站用户向我们的数据库提交文章时
http://www.netterweb.com/articles/ )他们几乎总是在文本中有http://
地址。他们将该文本粘贴到一个盒子中,以便将其保存到备忘录字段中。当通过网页上的结果显示时,链接处于非活动状态,除非用户知识足以在
文本中使用html。但是,我的大多数用户并不精通HTML。有没有办法我可以对该字段的结果进行编码,以便在http://之前的任何文本之间建立一个活动链接。 ?

提前感谢您的帮助。

Mike
When users of my site submit articles to our database
(http://www.netterweb.com/articles/) they almost always have http://
addresses within the text. They are pasting that text into a box which saves
to a memo field. When displayed through results on a webpage, the links are
inactive, unless the user was knowledgable enough to use html within the
text. However, most of my users are not html savvy. Is there a way I can
code the results of that field to make an active link out of any text
preceeded by "http://" ?

Thanks in advance for your help.

Mike



我想当你保存备忘录时,你可以找到.com,.org等等。如果找到

,那就去那个位置然后向后扫描,直到你找到一个

的空间(停下来然后上个字符) )或备忘录的开头。然后

检查http://是否是接下来的7个字符。如果没有,你可以

连接/插入 http://。


I suppose when you save the memo you could look for .com, .org, etc. If
it is found, go to that position and scan backwards until you hit a
space (stop and go up a character) or the beginning of the memo. Then
check if http:// is the next 7 characters. If not, you can
concatenate/insert the http://.


我是一个黑客和新代码。你能给我一个例子吗?


另外,我认为搜索http://或www会更好。然后转到

转发到某个空间,因为某些链接会以.com

或.net后结束。

$ b $你能举个例子吗?哪个适合写入数据库的SQL

语句?


感谢您的回复!

mike

" Salad" < oi*@vinegar.com>在消息中写道

新闻:电视******************* @ newsread1.news.pas.eart hlink.net ...
I''m kind of a hack and new to code. Can you give me an example to go by?

Plus, I think it would be better to search for http:// or www. and then go
forwards to a space, since some links will end with something after the .com
or .net.

Can you give me an example for that? Where would that fit into the SQL
statement that writes to the database?

thanks for your reply!
mike
"Salad" <oi*@vinegar.com> wrote in message
news:TV*******************@newsread1.news.pas.eart hlink.net...
magmike写道:
magmike wrote:
当我的网站用户向我们的数据库提交文章时
http://www.netterweb.com/articles/ )他们几乎总是在文本中有http://
地址。他们将该文本粘贴到一个框中,
保存到备注字段中。通过网页上的结果显示时,链接
处于非活动状态,除非用户知识足以在
文本中使用html。但是,我的大多数用户并不精通HTML。有没有办法我可以对该字段的结果进行编码,以便在http://之前的任何文本之间建立一个活动链接。 ?

提前感谢您的帮助。

迈克
When users of my site submit articles to our database
(http://www.netterweb.com/articles/) they almost always have http://
addresses within the text. They are pasting that text into a box which saves to a memo field. When displayed through results on a webpage, the links are inactive, unless the user was knowledgable enough to use html within the
text. However, most of my users are not html savvy. Is there a way I can
code the results of that field to make an active link out of any text
preceeded by "http://" ?

Thanks in advance for your help.

Mike


我想当您保存备忘录时,您可以寻找.com如果找到它,请转到那个位置并向后扫描,直到你到达
空间(停止并上升一个角色)或备忘录的开头。然后
检查http://是否是接下来的7个字符。如果没有,你可以
连接/插入 http://。



magmike写道:
magmike wrote:
我很亲切一个黑客和新的代码。你能给我一个例子吗?

另外,我认为搜索http://或www会更好。然后转到
转发到某个空间,因为某些链接会以.com
或.net之后的内容结束。


我应该添加...将需要进行错误检查。为什么不会&b
" www"够了吗?一个简单的例子是google,我经常去他们的

" groups"搜索... ex http://groups.google.com 。没有www。怎么

关于MS? http://support.microsoft.com 。 Nary awww周围。

你能给我一个例子吗?哪个适合写入数据库的SQL
语句?
I''m kind of a hack and new to code. Can you give me an example to go by?

Plus, I think it would be better to search for http:// or www. and then go
forwards to a space, since some links will end with something after the .com
or .net.
I should have added...error checking will be required. Why wouldn''t
"www" be sufficient? An easy example is google, I often go to their
"groups" search...ex http://groups.google.com. There is no "www". How
about MS? http://support.microsoft.com. Nary a "www" around.
Can you give me an example for that? Where would that fit into the SQL
statement that writes to the database?




我认为这是一个备忘录字段。如果是这样,我会在备忘录的afterupdate事件中更新备忘录

时更新它。例如:

如果Len(me.MemoFieldName)> 0然后

Me.MemoFieldName = CheckHttp(Me.MemoFieldName)

Endif


否则,在查询中,你会使用一个功能。如果你想通过查询更新备忘录,你可以将备忘录字段拖到查询中。

使查询类型更新。在更新行中输入

CheckHttp([YourMemoFieldName])


BTW,我会在你第一次运行它之前复制一下表格/>
如果你要通过

查询进行大规模更新,确保它能正常工作......但是从我站立的地方看来似乎没问题。


无论如何,这里的代码应该让你走上正轨。当我从立即/调试窗口调用它时,这是函数的结果



? CheckHttp(这是对 www.microsoft.com ,www.google.com的测试;)

它回应

这是 http://www.microsoft.com http://www.google。 com


好​​的......所以它主要起作用。你需要输入你想要检查的域名。

函数CheckHttp(varMemo As Variant)As Variant

Dim i作为整数

Dim intFor As Integer

Dim intPos as Integer

Dim intStart As Integer

Dim strHold As Variant


''更改计数器并添加任何其他域名以搜索

Dim ar(5)

ar(1) =" .www"

ar(2)=" .com"

ar(3)=" .org"

ar(4)=" .info"

ar(5)=" .biz"


''扫描每种类型

对于i = 1到5''在这里更改计数器如果你加/减ar计数

''在哪里开始搜索备忘录

intStart = 1


''永远做什么

做真的

''看看是否找到了搜索到的字符串

intPos = InStr(intStart,varMemo,ar(i))


''如果找不到则永远退出

如果intPos = 0则退出Do


''向后读回第一个非char或备忘录的开头

对于intFor = intPos到1步-1

''如果更少/ =空格,退出/下一个

如果是Mid(varMemo,intFor,1)< = Chr(32 )然后

''在空格后开始第一个字符

intFor = intFor + 1

退出

结束如果

下一个intFor


如果是Mid(varMemo,intFor,7)<> " HTTP://"然后

varMemo =左(varMemo,intFor - 1)& " HTTP://" &安培; _

Mid(varMemo,intFor)

结束如果


''开始搜索超出

intStart = intPos + Len(ar(i))


循环

下一页


CheckHttp = varMemo

结束功能



I thought this was a memo field. If so, I would update it when the memo
is updated, in the afterupdate event of the memo. Ex:
If Len(me.MemoFieldName) > 0 then
Me.MemoFieldName = CheckHttp(Me.MemoFieldName)
Endif

Otherwise, in a query, you would use a function. If you wanted to
update the memo via a query, you''d drag the memo field to the query.
Make the query type Update. In the Update row enter
CheckHttp([YourMemoFieldName])

BTW, I would make a copy of the table before you run it the first time
to ensure it works correctly if you will be doing a mass update via a
query...but it appears to be OK from where I''m standing.

Anyway, here is code that should get you on track. This is the result
of the function when I called it from the immediate/debug window
? CheckHttp("This is a test of www.microsoft.com, www.google.com")
and it echoes
This is a test of http://www.microsoft.com, http://www.google.com

OK...so it works mostly. You need to put in the domain name stuff you
want to check for.
Function CheckHttp(varMemo As Variant) As Variant
Dim i As Integer
Dim intFor As Integer
Dim intPos As Integer
Dim intStart As Integer
Dim strHold As Variant

''change the counter and add any further domains to search for
Dim ar(5)
ar(1) = ".www"
ar(2) = ".com"
ar(3) = ".org"
ar(4) = ".info"
ar(5) = ".biz"

''scan each type
For i = 1 To 5 ''change counter here if you add/subtract ar counts
''where to start searching in the memo
intStart = 1

''do forever
Do While True
''see if string searched for is found
intPos = InStr(intStart, varMemo, ar(i))

''exit forever if not found
If intPos = 0 Then Exit Do

''read backwards to first non-char or beginning of memo
For intFor = intPos To 1 Step -1
''if less/= space, exit for/next
If Mid(varMemo, intFor, 1) <= Chr(32) Then
''kick up to first char after space
intFor = intFor + 1
Exit For
End If
Next intFor

If Mid(varMemo, intFor, 7) <> "http://" Then
varMemo = Left(varMemo, intFor - 1) & "http://" & _
Mid(varMemo, intFor)
End If

''start search beyond
intStart = intPos + Len(ar(i))

Loop
Next i

CheckHttp = varMemo
End Function


这篇关于数据库结果 - 激活备注字段中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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