|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help with strings."<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 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. 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 Show quoteHide quote news:1141824954.279699.215770@u72g2000cwu.googlegroups.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. > 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. 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 Show quoteHide quote news:1141835294.828390.257940@p10g2000cwp.googlegroups.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. >
Adding button programatically - NON-FUNCTIONAL!!
Checking for new versions in a setup project Garbage collection and callbacks from unmanaged code. Preventing Explorer Window from Displaying when Pen Drive Inserted converting from combobox.text to long() Error on Graphics CompositingMode.SourceCopy Numeric Variables Can anyone convert this to VB? Getting Extended File Properties Email validation in grid |
|||||||||||||||||||||||