473,394 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help with strings.

Sample data.

"<td class=small bgcolor="E7E7E7">
Garth Was Here"

"<br><td class=small bgcolor="13B9C1">2006/03/08"

I'm looking for a two things.

1) A function to remove whitespaces. In the example data above not
only are there " " but there could be tabs and carriage returns.

2) I am also looking to strip off anything before the last ">" within
the string. I created a function that will do this for me, however for what
ever reason the InStrRev always returns 0. What I'm I doing wrong or how can
I fix this?

Public Function Clean_str(ByVal Str_in As String) As String

Dim Search As String

Dim Temp As String

Dim Temp2 As String

Dim start As Integer

Dim L As Integer

Search = "</td>"

L = Len(Search)

start = InStr(Str_in, Search, CompareMethod.Text)

Temp2 = Mid(Str_in, 1, start - 1)

Temp = Mid(Str_in, start + L)

'Find "> which is before the Date"

Search = "<br>"

start = InStr(Temp2, Search, CompareMethod.Text)

Temp2 = Mid(Temp2, 1, start - 1)

Search = ">"

start = InStrRev(Temp2, Search, CompareMethod.Text)

L = Len(Search)

Temp2 = Mid(Temp2, start + L)

Temp2 = Trim(Temp2)

Return Temp2

End Function
Mar 8 '06 #1
4 1408
Are you using VB6? If so, you are posting in the wrong newsgroup. If
you are using VB.NET, you should look into the String class and all of
the properties and method available for manipulating string values.

Mar 8 '06 #2
I'm using "Microsoft Visual Basic 2005 Express Edition" I have read the Help
file included but there does not seem to be a reason why the InStrRev always
returns 0. Also there does not seem to be a Whitespace function.

Personally I find that the help file is less than helpful, I much prefer the
help file that SQL server 2000 has to find out more about function and how
they work.

<za***@construction-imaging.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Are you using VB6? If so, you are posting in the wrong newsgroup. If
you are using VB.NET, you should look into the String class and all of
the properties and method available for manipulating string values.

Mar 8 '06 #3
Sound like you have yet to grasp the concepts of OOP.

The InStrRev always returning 0 probably means you have your previous
Mid function coded incorrectly. Try to dump the value of Temp2 before
the InStrRev call to make sure.

You really need to start using the String class methods to manipulate
strings, the functions you are using are merely provided for backwards
compatiblilty with VB6.

For removing things like whitespace, most people use the String.Replace
method.

Mar 8 '06 #4
You are right about the oop. Many moons ago when the grass was green I
programmed in C and Turbo Pascal since then I have done mostly scripting.
And I love my command prompt and winfile.exe too! <Grin>

I did find the Object.trim which does exactly what I want it to do. Also I
think that I have over come my huddles for now and the function work fine.
:-)

Thanks for pointing me in the right direction.

<za***@construction-imaging.com> wrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
Sound like you have yet to grasp the concepts of OOP.

The InStrRev always returning 0 probably means you have your previous
Mid function coded incorrectly. Try to dump the value of Temp2 before
the InStrRev call to make sure.

You really need to start using the String class methods to manipulate
strings, the functions you are using are merely provided for backwards
compatiblilty with VB6.

For removing things like whitespace, most people use the String.Replace
method.

Mar 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jack Smith | last post by:
Can some one help me with this proof? Let L be the language of strings over {a,b} recursively defined by the following set of rules (i) the string ^ is in L (^ is the null string). (ii) for...
5
by: ArShAm | last post by:
Hi there Please help me to optimize this code for speed I added /O2 to compiler settings I added /Oe to compiler settings for accepting register type request , but it seems that is not allowed...
3
by: Mahmood Ahmad | last post by:
Hello, I have written a program that reads three types of records, validates them acording to certain requirements and writes the valid records into a binary file. The invalid records are...
0
by: Jon | last post by:
We have a asp.net app that runs like the following in a single-site scenario. Directory structure: c:\inetpub\wwwroot\myapp - aspx files, global.asax and web.config c:\inetpub\wwwroot\myapp\bin...
9
by: Diane | last post by:
Could you please explain me how can I output nested strings? Here is an example: "adsd{rfkm}xcv" The output should start from the inner parentheses, such as: dfF rfkm
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
4
by: Robin Haswell | last post by:
Okay I'm getting really frustrated with Python's Unicode handling, I'm trying everything I can think of an I can't escape Unicode(En|De)codeError no matter what I try. Could someone explain to...
2
by: almurph | last post by:
Hi, Hope you can help me. This is a trick one - at least I think so. I have 2 strings. I have to calculate the "score" of the strings. Score is determined by matching patterns of letters within...
4
by: Debbiedo | last post by:
My software program outputs an XML Driving Directions file that I need to input into an Access table (although if need be I can import a dbf or xls) so that I can relate one of the fields...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.