在vb里怎么把文本框里的文字内容的所有链接都截取出来?
比如说<ahref=http://go.sohu.com/45nm/index.php/Open/indextarget=_blank>Intel网络运动会惊现超级BT视...
比如说
<a href=http://go.sohu.com/45nm/index.php/Open/index target=_blank>Intel网络运动会惊现超级BT视频</a><br><a href="http://club.it.sohu.com/itmain.php?b=nightofit&c=69" target=_blank>IT夜生活</a><br><a href="http://club.it.sohu.com/itmain.php?b=nightofit&c=70">IT夜生活1</a><br><a href=http://club.it.sohu.com/itmain.php?b=nightofit&c=71>IT夜生活2</a>
我就想要http://go.sohu.com/45nm/index.php/Open/index 和http://club.it.sohu.com/itmain.php?b=nightofit&c=69和http://club.it.sohu.com/itmain.php?b=nightofit&c=70 和http://club.it.sohu.com/itmain.php?b=nightofit&c=71 。 展开
<a href=http://go.sohu.com/45nm/index.php/Open/index target=_blank>Intel网络运动会惊现超级BT视频</a><br><a href="http://club.it.sohu.com/itmain.php?b=nightofit&c=69" target=_blank>IT夜生活</a><br><a href="http://club.it.sohu.com/itmain.php?b=nightofit&c=70">IT夜生活1</a><br><a href=http://club.it.sohu.com/itmain.php?b=nightofit&c=71>IT夜生活2</a>
我就想要http://go.sohu.com/45nm/index.php/Open/index 和http://club.it.sohu.com/itmain.php?b=nightofit&c=69和http://club.it.sohu.com/itmain.php?b=nightofit&c=70 和http://club.it.sohu.com/itmain.php?b=nightofit&c=71 。 展开
2个回答
展开全部
'复制下面代码,保存为Form1.frm,然后双击打开,运行,按command1按钮,就会看到结果。
'====Form1.frm====
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4800
ClientLeft = 60
ClientTop = 450
ClientWidth = 7440
LinkTopic = "Form1"
ScaleHeight = 4800
ScaleWidth = 7440
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 5760
TabIndex = 2
Top = 960
Width = 855
End
Begin VB.ListBox List1
Height = 1500
Left = 120
TabIndex = 1
Top = 3000
Width = 4575
End
Begin VB.TextBox Text1
Height = 2415
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Text = "Form1.frx":0000
Top = 240
Width = 4575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim i As Long, S As String, Tz As String, Tmp As String
Dim Urls As String
Tz = " href="
S = Text1.Text
Do While InStr(1, S, Tz, vbTextCompare) > 0
i = InStr(1, S, Tz, vbTextCompare)
S = Mid(S, i + Len(Tz))
i = InStr(S, ">")
Urls = Left(S, i - 1)
Urls = Replace(Urls, Chr(34), "")
Urls = Replace(Urls, "target=_blank", "", , , vbTextCompare)
List1.AddItem Urls
Loop
End Sub
'====Form1.frm====
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4800
ClientLeft = 60
ClientTop = 450
ClientWidth = 7440
LinkTopic = "Form1"
ScaleHeight = 4800
ScaleWidth = 7440
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 5760
TabIndex = 2
Top = 960
Width = 855
End
Begin VB.ListBox List1
Height = 1500
Left = 120
TabIndex = 1
Top = 3000
Width = 4575
End
Begin VB.TextBox Text1
Height = 2415
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Text = "Form1.frx":0000
Top = 240
Width = 4575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim i As Long, S As String, Tz As String, Tmp As String
Dim Urls As String
Tz = " href="
S = Text1.Text
Do While InStr(1, S, Tz, vbTextCompare) > 0
i = InStr(1, S, Tz, vbTextCompare)
S = Mid(S, i + Len(Tz))
i = InStr(S, ">")
Urls = Left(S, i - 1)
Urls = Replace(Urls, Chr(34), "")
Urls = Replace(Urls, "target=_blank", "", , , vbTextCompare)
List1.AddItem Urls
Loop
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询