Results 1 to 12 of 12

Thread: How to arrange strings like that?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    How to arrange strings like that?

    Hello
    It's my 2nd day im working on a function to arrange any string in a certain pattern, and after all my efforts im forwarding this query here.

    I want to arrange any string like -
    Suppose the string is "google" Now i want to arrange them in a listbox as -

    g-oogle
    go-ogle
    goo-gle
    goog-le
    googl-e
    g-o-o-g-l-e
    g-o-gle


    and so on [all possible patterns (without any duplicate entry)]..

    Note: "-" can be many times but shouldn't be duel like "go--ogle"

    I hope you can help me on this

    Thanks
    Regards,
    Last edited by green.pitch; Feb 19th, 2013 at 01:29 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: How to arrange strings like that?

    It is simply a matter of looping and breaking the string into pieces inserting the character.

    Show us what you have so far and maybe we can point you in the right direction

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: How to arrange strings like that?

    Hi DataMiser,
    It's not as much simple for me..
    See this link. It's the demonstration I want to do same in vb6.
    Code:
    www+exploitn+com/gmail.php


    Ok Here I am doing like this-
    Code:
    Option Explicit
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As Long
    
    Private Const LB_FINDSTRINGEXACT = &H1A2
    
    Private Sub AddToListbox(strListBItem As String, LB As ListBox)
    
        Dim lngListIndex As Long
        
        ' lngListIndex is the ListIndex if the item is found
        lngListIndex = SendMessage(LB.hwnd, LB_FINDSTRINGEXACT, -1, ByVal strListBItem)
        If lngListIndex = -1 Then
            LB.AddItem strListBItem
        Else
            DoEvents
            Exit Sub
        End If
    End Sub
    
    Private Sub Command1_Click()
        Dim S As String, i As Long, R As String, X As String
        S = "google"
        For i = 1 To Len(S) - 1
            R = Left(S, i) & "." & Right(S, Len(S) - i)
            If Right$(R, 1) <> "." Then AddToListbox Replace(R, "..", "."), List1
        Next i
        
        Dim J As Long, K As Long
        For J = 0 To List1.ListCount - 1
            S = List1.List(J)
            For i = 1 To Len(S)
                R = Left(S, i) & "." & Right(S, Len(S) - i)
                X = Replace(R, "..", ".")
    'remove duplicates
                If Right$(X, 1) <> "." Then AddToListbox X, List1
                DoEvents
            Next i
        Next J
        Me.Caption = List1.ListCount
    
    End Sub
    But it's generating only 15 entries, and above URL is generating 32 entries.


    Thanks
    Regards,
    Last edited by green.pitch; Feb 19th, 2013 at 02:37 AM. Reason: added codes

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: How to arrange strings like that?

    Sorry but no. I am not going to some web site to see a demo especially not one named exploitn

    You say you are on your 2nd days working on this so surely you have written some code. Show us what you have and tell us what problem you are having then maybe we can help.

    May also be nice to know why you want to do this as there does not seem to be much in the way of practical use for it.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: How to arrange strings like that?

    Okies, I have already modified my last previous post to add my codes. You can check them.. And Ok if you don't want to go to that URL, you check the attached snapshot here.

    Name:  gg.png
Views: 200
Size:  14.9 KB

    Thanks !

  6. #6
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: How to arrange strings like that?

    Check post #5 in this thread. It should get you there. http://www.vbforums.com/showthread.p...=1#post4301705

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: How to arrange strings like that?

    Is this what you need? Put a command button, a textbox and a listbox on a form....put your string in the textbox and click on the cmdbtn

    Code:
    private sub Command1_click()
    Dim x As Integer, y As Integer, myText As String
    myText = Trim(Text1.Text)
    y = 0
    For x = 1 To Len(myText) - 1
        myText = Left(myText, 0 + (y)) & Mid(myText, y + 1, 1) & "," & Mid(myText, y + 2)
        List1.AddItem myText
        y = y + 2
    Next x
    End Sub

  8. #8
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: How to arrange strings like that?

    I guess it would be easier for her/him if we would post our EMail directly, instead of having her/him trying to find it by brute-forcing all possible ones. :sarcastic:
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  9. #9
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: How to arrange strings like that?

    Quote Originally Posted by SamOscarBrown View Post
    Is this what you need? Put a command button, a textbox and a listbox on a form....put your string in the textbox and click on the cmdbtn

    Code:
    private sub Command1_click()
    Dim x As Integer, y As Integer, myText As String
    myText = Trim(Text1.Text)
    y = 0
    For x = 1 To Len(myText) - 1
        myText = Left(myText, 0 + (y)) & Mid(myText, y + 1, 1) & "," & Mid(myText, y + 2)
        List1.AddItem myText
        y = y + 2
    Next x
    End Sub
    That misses many possibilities. Take a look at the list in Post #5.
    Doctor Ed

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: How to arrange strings like that?

    Quote Originally Posted by MarkT View Post
    Check post #5 in this thread. It should get you there. http://www.vbforums.com/showthread.p...=1#post4301705
    Greetings,
    Thanks to all of you for your valuable replies.
    Thank you so much MarkT, that URL is perfectly working..

    I will try to learn many more with this.

    Regards,

  11. #11
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: How to arrange strings like that?

    Quote Originally Posted by opus View Post
    I guess it would be easier for her/him if we would post our EMail directly, instead of having her/him trying to find it by brute-forcing all possible ones. :sarcastic:
    lmao: they got time for such in life , they want to get rich thats allthis is why they do itidiots

  12. #12
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: How to arrange strings like that?

    OH...SO sorry.....didn't read very well, did I. Please accept my apologies for wasting your time.

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