Hey Guys,
First time here, i usually resort to google (but for the first time in 3 years he (or she) cant help me) ... Im making some software that generates html reports which can be viewed within the program and they're exported with bookmark links so that when you click a link (bookmark) it adds the bookmark to the end of the address (changes the window to http://address/file.html#timmy) as this happens the program realises the address has changed so it grabs the new address and sticks it into a string ... i then want to strip that string anything before and including the #.
so in this case i want to be left with the word timmy
(in actual terms, this well be a membership number not a name but it shouldnt make any difference )
i have this, but it keeps returning nothing. Perhaps it'll give you something to work with ... - Public Function DeleteString( _
-
ByVal vString As Variant _
-
, Optional ByVal vStartPos As Variant _
-
, Optional ByVal vLength As Variant _
-
) As Variant
-
-
End Function
-
-
Public Sub addresschange()
-
Dim address As String
-
Dim membername As String
-
-
address = web.LocationURL
-
findbm = "#"
-
thename = InStr(address, findbm)
-
membername = DeleteString(address, 1, thename)
-
-
MsgBox membername 'membername is null ??
-
-
end sub
ignore how the program recognises how the routine is called, i simply want to strip the string ... could someone put me out my misery please :)
7 1384
Because you did not mention what version of Visual Basic you are writing in, I'm going to assume 2005. :)
Anyway, it's a very simple process to extract a string using the String.substring and String.IndexOf methods: -
Dim address As String = "http://address/file.html#timmy"
-
Dim strMemberName As String
-
strMemberName = address.Substring(address.IndexOf("#") + 1)
-
The substring method parameters are startIndex and length. If length is omitted the substring returned is from startIndex to the end of the string, including startIndex.
The IndexOf method returns the index of a specific character in a string. Because there can only be one octothorpe in any given URI you get the index of that specific character. Since you do not want the octothorpe included you add one to the returned index.
Hope that helps.
i have this, but it keeps returning nothing. Perhaps it'll give you something to work with ...
Looks to me as though it's returning nothing because the DeleteString routine does nothing. Perhaps you left something out, there?
By the way, cugone, though I could be mistaken, I think the use of Variant data type probably indicates VB6. Wasn't that replaced by Object in VB.Net?
Looks to me as though it's returning nothing because the DeleteString routine does nothing. Perhaps you left something out, there?
By the way, cugone, though I could be mistaken, I think the use of Variant data type probably indicates VB6. Wasn't that replaced by Object in VB.Net?
Why yes, yes it was I didn't notice it because he said not to pay attention to that routine. :/ Well, code937, if you ever switch to 2005, that's how you do it.
Why yes, yes it was I didn't notice it because he said not to pay attention to that routine. :/
First law of debugging, I think - don't believe what anyone tells you, check it out for yourself. :)
Hey guys, I almost forgot I posted this until I went back to this part of the program and realised I still hadn't worked out how to do this. Yeah I'm using VB6 still ... I know I should update (of which I have got a copy of .Net) but I can do so much in VB6 that I wouldn't have a clue about in .Net .... anywho, I'm gunna check out that bit of code in VB6.
Cheers
--- update, no because I'm using VB6 that code doesnt work :$ --
Any chance of a lickle teeny bit more guidance?
i hate to bump the thread but can anyone else help ? :)
i hate to bump the thread but can anyone else help ? :)
:O How rude! ;)
Let's see, if I remember correctly (after a quick flick back through the thread), you want a VB6 routine to take something like "http://address/file.html#timmy" and return the part after the "#". Seems simple enough. - Public Function Version1(ByVal OriginalString As String, ByVal Delimiter As String) As String
-
Version1 = Split(OriginalString, Delimiter)(1)
-
End Function
-
-
Public Function Version2(ByVal OriginalString As String, ByVal Delimiter As String) As String
-
Version2 = Mid$(OriginalString, InStr(1, OriginalString, Delimiter) + 1)
-
End Function
There's two different functions that do much the same thing - take you pick.
Note that this is more or less "proof of concept" code. It doesn't take into account situations such as empty strings, no "#" in the string, and so on.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hank |
last post by:
Hi,
I have this problem with string.rstrip
Python 2.2.3 (#42, May 30 2003, 18:12:08) on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>>...
|
by: Brian |
last post by:
Hello - has anyone else had trouble with string.lstrip stripping too
much? Here's what I get (Python 2.3.4):
>>> import string
>>> string.lstrip("test/one/two/a.b.c", "test/one/")
'wo/a.b.c'...
|
by: beliavsky |
last post by:
The code
for text in open("file.txt","r"):
print text.replace("foo","bar")
replaces 'foo' with 'bar' in a file, but how do I avoid changing text
inside single or double quotes? For making...
|
by: Yuri Vanzine |
last post by:
Saw this requested awhile ago on Matthew Reynolds's blog here:
http://www.dotnet247.com/247reference/msgs/11/57944.aspx
Problem: often times I deal with querystring-formatted strings w/o the...
|
by: electrixnow |
last post by:
in MS VC++ Express I need to know how to get from one comma delimited
text string to many strings.
from this:
main_string = "onE,Two,Three , fouR,five, six "
to these:
string1 =...
|
by: Senger |
last post by:
Hello,
I need separete a string in 2 blocks.
For example:
Which is my favourite fruit?|Orange
Which is my favourite color?|Blue
|
by: micklee74 |
last post by:
hi
if i have a some lines like this
a ) "here is first string"
b ) "here is string2"
c ) "here is string3"
When i specify i only want to print the lines that contains "string" ie
the first...
|
by: G |
last post by:
Hello,
Does anyone have any code handy which will take a certain part of a string
and save it as an independant string?
For example:
"Thank you for visiting our web site. You were sent...
|
by: Colin J. Williams |
last post by:
The Library Reference has
strip( )
Return a copy of the string with the
leading and trailing characters removed.
The chars argument is a string
specifying the set of characters to be
removed....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |