Results 1 to 4 of 4

Thread: [2008] Find all strigns of a certian length?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    [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

  2. #2
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    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)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    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

  4. #4
    Addicted Member joe1985's Avatar
    Join Date
    Jun 2007
    Posts
    151

    Re: [2008] Find all strigns of a certian length?

    Yes, use regular expressions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width