Copy Hyperlink inserts a Hash Sign #... How can I remove it?

B

bobdydd

Hi

I am trying to copy a web address eg
http://www.mysite.com

to a textbox called "txttrunc1" and strip away
the http://www. so that only the
mysite.com is left
by using the code below.

But it keeps adding a # "hash sign
so that I end up with mysite.com#

How can I remove the final #
Thanks
Bill

Private Sub Command65_Click()
Dim MyLine As String
MyLine = Me.txtPageAddress
MyLine = Mid(MyLine, 13, Len(MyLine) - 1)
Me.txttrunc1 = MyLine
End Sub
 
P

put_upon

Thanks Salad that got me thinking in the right direction
I ended up using this code

Dim Address As String
Dim Stripped As String
Dim length As Integer
Address = Me.txtPageAddress
Stripped = Mid(Address, 13)
length = Len(Stripped)
Me.txttrunc1 = Mid(Address, 13, length - 1)

and that got rid of the extra hash # sign

Thanks for your help
 
P

Paul Shapiro

You might want to do it more reliably, in case the # sign or www. is not
always included:

Address = Me.txtPageAddress.value
'Remove the http://www.
If Left(Address, 11) = "http://www." Then
Address = Right(Address, len(Address) - 11)
ElseIf Left(Address, 7) = "http://" Then
Address = Right(Address, len(Address) - 7)
End If
'Remove a trailing #
If Right(Address, 1) = "#"
Address = Left(Address, len(Address) - 1)
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top