|
-
Mar 5th, 2006, 07:44 AM
#1
Thread Starter
Frenzied Member
hyperlink in text box
is it possible to put a hyperlink in a textbox?
-
Mar 5th, 2006, 08:16 AM
#2
Re: hyperlink in text box
Providing there was nothing else in the textbox, it would be very easy.
If, however, the textbox was loaded with text, one line of which was a hyperlink, then you need to go to a richtextbox. This has the capability of singling out individual lines of text and taking some type of action on them.
-
Mar 5th, 2006, 08:40 AM
#3
Frenzied Member
Re: hyperlink in text box
I am really not sure what you mean.
If you have nothing more then the website in it you can, but if you have other text in it then the richtextbox is the way.
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMAXIMIZED = 3
Private Sub Form_Load()
Text1.Text = "www.vbforums.com"
End Sub
Private Sub Text1_Click()
ShellExecute ByVal 0&, "open", "http://www.vbforums.com/", _
vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
-
Mar 5th, 2006, 08:43 AM
#4
Thread Starter
Frenzied Member
Re: hyperlink in text box
i mean like
Text2.Text = www.hotmail.com
and i want that text to be hyperlinked (as in go blue and underlines) so users can click on the text and the hotmail page will open
-
Mar 5th, 2006, 09:23 AM
#5
New Member
Re: hyperlink in text box
You may want to check out my post. the code seems similiar...
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Sub Form_Load()
load_site
End Sub
Public Function load_site()
If InternetCheckConnection("http://www.vbforums.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
'There is no connection to site
MsgBox App.EXEName & " was unable to connect to site", vbInformation, App.EXEName
Else
ShellExecute Me.hwnd, "open", "www.vbforums.com", vbNullString, "C:\", SW_SHOWNORMAL
End If
End Function
'if you take out the portion
"If InternetCheckConnection("http://youraddresshere.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
'There is no connection to site
MsgBox App.EXEName & " was unable to establish a valid internet connection", vbInformation, App.EXEName
Else
ShellExecute Me.hwnd, "open", "http://youraddresshere.com", vbNullString, "C:\", SW_SHOWNORMAL
End If"
and add it to a command button, it will launch the site in question. hope this helped.
btw the above code was not created by me, so credit is due.
Last edited by Hack; Mar 6th, 2006 at 07:23 AM.
Reason: Added [vbcode] [/vbcode] tags and for more clarity.
-
Mar 6th, 2006, 07:23 AM
#6
Re: hyperlink in text box
See Rhinobull's example project here
-
Mar 6th, 2006, 12:32 PM
#7
Re: hyperlink in text box
If its the only text in the textbox then you can do it without a RTB. Just in the MouseMove event change the font style so its underlines and change the forecolor. Then when it moves out restore the original font serttings.
Use the Click example code already posted to execute the link.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|