|
-
Feb 19th, 2013, 01:08 AM
#1
Thread Starter
Lively Member
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.
-
Feb 19th, 2013, 02:28 AM
#2
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
-
Feb 19th, 2013, 02:31 AM
#3
Thread Starter
Lively Member
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
-
Feb 19th, 2013, 02:37 AM
#4
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.
-
Feb 19th, 2013, 03:24 AM
#5
Thread Starter
Lively Member
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.

Thanks !
-
Feb 19th, 2013, 07:50 AM
#6
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
-
Feb 19th, 2013, 10:29 AM
#7
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
-
Feb 19th, 2013, 10:46 AM
#8
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!
-
Feb 19th, 2013, 08:51 PM
#9
Re: How to arrange strings like that?
 Originally Posted by SamOscarBrown
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.
-
Feb 19th, 2013, 11:21 PM
#10
Thread Starter
Lively Member
Re: How to arrange strings like that?
 Originally Posted by MarkT
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,
-
Feb 20th, 2013, 02:50 AM
#11
Banned
Re: How to arrange strings like that?
-
Feb 20th, 2013, 06:13 AM
#12
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|