[2008] Find all strigns of a certian length?
Hey!
What I'm trying to do is scan a txtbox, and add all the strings that are 32 chars long to my listbox. I found this function:
Code:
Public Function GBA(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, ByVal lstAdd As ListBox, Optional ByRef startPos As Integer = 0) As String
Dim iPos As Integer, iEnd As Integer, strResult As String, lenStart As Integer = strStart.Length
Do Until iPos = -1
strResult = String.Empty
iPos = strSource.IndexOf(strStart, startPos)
iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
lstAdd.Items.Add(strResult)
startPos = iPos + lenStart
End If
Loop
GBA = ""
End Function
But it doesn't really help me :P
I also found
Code:
if string1.length = 32 then....
but I don't know how I can use it.
Thanks,
Alex
Re: [2008] Find all strigns of a certian length?
You've got it right there!
Code:
If String1.Length = 32 Then ListBox1.Items.Add(String1)
Re: [2008] Find all strigns of a certian length?
String1 is nonexistent. I was just using it as an example ;)
I think I found a way how to do this, but I need to be able to use wildcards.
Are there any wild cards for vb.net?
eg.
If I searched for "12345##", "1234582" would be true
if I searched for "abc*", abcf3jffn___safn" would be true
if I searched for "abc^g#", "abcxg8" would be true
Re: [2008] Find all strigns of a certian length?
Yes, use regular expressions.