| View previous topic :: View next topic |
| Author |
Message |
wohawsnng Cheater
Reputation: 0
Joined: 08 Dec 2007 Posts: 33
|
Posted: Thu Jan 03, 2008 7:29 am Post subject: [VB6] Generate alphabets and numbers in squence |
|
|
How can I like generate all the possible 6 character strings that includes
a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9
and then storing it in a text file or displaying it one by on in a text box in visual basic?
|
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 03, 2008 9:52 am Post subject: |
|
|
I don't quite understand what you mean. Could you please rephrase it?
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Jan 03, 2008 10:41 am Post subject: |
|
|
| I don't know about VB, but in the rest of the languages characters are treated as their ascii values. (so if you do "if (var1 == 122)" its the same as "if (var1 == 'z')", I think its z...)
|
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 03, 2008 2:20 pm Post subject: |
|
|
In VB, you don't use ASCII like that. You use it for key presses and stuff. To get a variable to have the value 'z' you use
| Code: |
Dim Blah As String
Blah = "z"
|
~Elec0
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Jan 03, 2008 2:50 pm Post subject: |
|
|
He wants to know how he can generate all possible 6 string characters that can be made out of:
abcdefghijklmnopqrstuvwxyz1234567890
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Thu Jan 03, 2008 10:16 pm Post subject: |
|
|
In C# it'd be like this:
| Code: |
string[] TheStuff = new char[36];
TheStuff = { "a", "b", "c", "d", "e", "f", "g", ... "0", "1", "2", ... "8", "9" };
string lulz = "";
for (int i = 0; i < TheStuff.Length; i++) //you could use 36, but this is
//more generic
{
for (int j = 0; j < TheStuff.Length; j++)
{
for (int k = 0; k < TheStuff.Length; k++)
{
for (int l = 0; l < TheStuff.Length; l++)
{
for (int m = 0; m < TheStuff.Length; m++)
{
for (int n = 0; n < TheStuff.Length; n++)
{
lulz = TheStuff[i] + TheStuff[j] + TheStuff[k] + TheStuff[l] + TheStuff[m] + TheStuff[n];
MYTEXTBOXNAME.Text += Lulz;
}
}
}
}
}
}
|
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Jan 04, 2008 6:20 am Post subject: |
|
|
This takes quiet a while to do in VB, the code is pretty basic, just like samuri25404's code, just in VB:
(In a module.)
| Code: | Option Explicit
'//------------------------------------------------------
'// There are 26 letters in the alphabet
'// a = 1
'// ...
'// z = 26
'// 0 to 9 would make it 36
'//------------------------------------------------------
Public AlphaArray(35) As Byte
'// Fill The Array With The Information
Public Sub FillArray()
AlphaArray(0) = "a"
AlphaArray(1) = "b"
AlphaArray(2) = "c"
AlphaArray(3) = "d"
AlphaArray(4) = "e"
AlphaArray(5) = "f"
AlphaArray(6) = "g"
AlphaArray(7) = "h"
AlphaArray(8) = "i"
AlphaArray(9) = "j"
AlphaArray(10) = "k"
AlphaArray(11) = "l"
AlphaArray(12) = "m"
AlphaArray(13) = "n"
AlphaArray(14) = "o"
AlphaArray(15) = "p"
AlphaArray(16) = "q"
AlphaArray(17) = "r"
AlphaArray(18) = "s"
AlphaArray(19) = "t"
AlphaArray(20) = "u"
AlphaArray(21) = "v"
AlphaArray(22) = "w"
AlphaArray(23) = "x"
AlphaArray(24) = "y"
AlphaArray(25) = "z"
AlphaArray(26) = "0"
AlphaArray(27) = "1"
AlphaArray(28) = "2"
AlphaArray(29) = "3"
AlphaArray(30) = "4"
AlphaArray(31) = "5"
AlphaArray(32) = "6"
AlphaArray(33) = "7"
AlphaArray(34) = "8"
AlphaArray(35) = "9"
End Sub
'// Loop Array For Each Possible Clause And Report To Textbox
Public Function LoopArray()
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim e As Long
Dim f As Long
For a = 0 To UBound(AlphaArray)
For b = 0 To UBound(AlphaArray)
For c = 0 To UBound(AlphaArray)
For d = 0 To UBound(AlphaArray)
For e = 0 To UBound(AlphaArray)
For f = 0 To UBound(AlphaArray)
With Form1.Text1
.Text = .Text & (AlphaArray(a) & AlphaArray(b) & AlphaArray(c) & AlphaArray(d) & AlphaArray(e) & AlphaArray(f)) & vbNewLine
End With
DoEvents '// Let VB Catchup
Next f
Next e
Next d
Next c
Next b
Next a
End Function
|
Yea yea, I know theres better ways to fill the array, but that was the fastest for me to type up real quick. Anyway, just call LoopArray in your command button and make sure to add a textbox (text1.text) that is multiline for this to write to.
Again this is going to take ages for VB to do so have fun waiting.
_________________
- Retired. |
|
| Back to top |
|
 |
wohawsnng Cheater
Reputation: 0
Joined: 08 Dec 2007 Posts: 33
|
Posted: Fri Jan 04, 2008 9:23 am Post subject: |
|
|
Thank you very much!
|
|
| Back to top |
|
 |
|