ورود

View Full Version : سوال: Hyperlink كردن متن در RichTextBox



Golsha
پنج شنبه 19 شهریور 1388, 17:04 عصر
ببخشيد دوستان ميخواستم ببينم چه طوري ميشه تو RichTextBox به صورت Hyperlink نوشت يعني وقتي متني رو انتخاب كردي و دكمه رو كليك كردي متني كه تو RichTextBox وجود داره طوري بشه كه وقتي روش كليك كردي بره تو سايت گوگل ؟؟؟

Cancer
جمعه 20 شهریور 1388, 02:42 صبح
Private Sub Form_Load()
Text1.Text = "http://www.barnamenevis.org"
End Sub
Private Sub Text1_Click()
Shell "Explorer.exe" + " " + Text1.Text, vbNormalFocus
End Sub


شاید این بدردت بخوره
:متفکر:اگه منظورت درست متوجه شده باشم

Golsha
جمعه 20 شهریور 1388, 15:31 عصر
دوست عزيز همين كه نوشتي خوبه ولي من منظورم اينه كه روي يه قسمتي از متن كليك كرد بره تو اينترنت يعني اينجوري

مثلا :


dsgfashgfshdgfshdbsydgvdsfguysdfvdsfguysdgsadgbvvu sdfgusydgfusydgf

حالا اگه روي قسمت آبي اگه كليك كرد بره تو يه سايت .

Golsha
شنبه 21 شهریور 1388, 14:51 عصر
كسي نيست جواب بده ؟؟؟

xxxxx_xxxxx
شنبه 21 شهریور 1388, 18:37 عصر
Private Sub Form_Load()

GetThisHyperLink = InputBox("HyperLink?", "Please enter a WebPage", "http:\\www.tek-tips.com")
GetThisHyperLink = Replace(GetThisHyperLink, "\\", "\\\\", 1)

Me.RichTextBox1 = "{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}" & Chr(13) & _
"{\colortbl ;\red0\green0\blue255;} " & Chr(13) & _
"\viewkind4\uc1\pard\lang1033\f0\fs17 This would be the non hyperlink beginning of the richtext box \cf1\ul " & GetThisHyperLink & "\cf0\ulnone and this would be the end of the non hyperlink text" & Chr(13) & _
"\par }"


End Sub

Private Sub RichTextBox1_Click()
With Me.RichTextBox1
If .SelColor = vbBlue And .SelUnderline Then
'find the beginning of the Hyperlink
For I = .SelStart To 1 Step -1
.SelStart = I
If .SelStart = I Then 'sometimes the .SelStart doesn't change..this is the work around
If Not .SelUnderline Then
Exit For
End If
End If
Next I
StartPos = .SelStart
'Find the end of the Hyperlink
For I = .SelStart + 1 To Len(Me.RichTextBox1)
.SelStart = I
If .SelStart = I Then 'sometimes the .SelStart doesn't change..this is the work around
If Not .SelUnderline Then
Exit For
End If
End If
Next I
EndPos = .SelStart - 1
'Now Scrape HyperLink
.SelStart = StartPos
.SelLength = EndPos - StartPos
MyHyperLink = .SelText
.SelStart = 1
.SelLength = 0
'Now launch internet explorer to that page
Shell """C:\Program Files\Internet Explorer\IExplore.exe """ & MyHyperLink, vbNormalFocus
End If
End With
End Sub


منبع: http://www.tek-tips.com/faqs.cfm?fid=4936

Golsha
یک شنبه 22 شهریور 1388, 16:37 عصر
دوست عزيز ممنون ولي اين يه مشكلي داره

اگه متني كه روش كليك ميكنيم آدرس يه سايت باشه ميره تو اون سايت ولي سوال من اينطور بود كه مثلا :

مسعود گوهري گلشن

حالا اگه روي گوهري كليك كرد مثلا بره تو سايت گوگل ولي اوني كه شما نوشتي بايد اينطوري باشه تا وقتي روي قسمت آبي كليك كردي بره توي سايت گوگل


www.google.com