Generator

Wizzard
10-08-2001, 02:57 AM
Hey,

I have to make something for school but i don't know how make it.
I explain :
AbcDeF

the A,D,F must change with letters like = A,D,F,J,K,L,M,N,O,P
but none of the letters must be the same like
like AbcAeF is wrong it must be something like this :
AbcDeF
AbcDeJ

till the last letter and then you have to change the other letters like :
DbcAeF
DbcAeJ
can someone helps me with this?

Greetz
Wizzard

Ad1
10-08-2001, 03:28 AM
firstly check tutors corner to find out about generating random numbers, then use ASCII to convert these numbers into letters, use a variable array to keep track of letters generated so far so as to prevent duplicates. You can use a select case to see if it is one of your particular letters and if so subtract 32 from the ascii value to capitalize it or use UCase()

Yoda
10-08-2001, 03:31 AM
Wizzard,

Your project isn't that hard at all. I suggest you try searching for some info on loops, arrays and especially nested loops.

Before you ask questions, you should at least start and try yourself, and then ask specific questions for specific problems.

I'm afraid noone here's going to do your homework for you, but don't worry - you can do it !

One way to start is write down a series of output lines as they should be and try to distinguish certain patterns or loops in them.

Good luck !

<font color=green>Do or do not
There is no try</font color=green>

Wizzard
10-08-2001, 03:41 AM
Yoda,

Can you explain i'm beginner into visualbasic but don't know what you mean with patterns i know loops like for next do while ...
but don't know anything about array's
I tried already more than 40hours on this exercise.
I just need some help to start.

Yoda
10-08-2001, 04:02 AM
Okay,

As I understand it, the b, c and e always stay where they are.
This means you'll have to find combinations of three letters out of a possible A,D,F,J,K,L,M,N,O,P.

Now you can start writing possibilities :
AbcDeF
AbcDeJ
...
AbcDeP

AbcFeJ
AbcFeK
...
AbcFeP

Forget about the b, c and e for a minute. We have :
ADF
ADJ
...
ADP

AFJ
AFK
...
AFP

Now forget about the letters for a moment. Notice how your teacher gave you 10 letters ? There are 10 numbers, aren't there ?

So let's make an array :

Dim LetterArray As String
LetterArray(0) = "A"
LetterArray(1) = "D"
...
LetterArray(9) = "P"

What you got to do now is make all possible 3-number combinations with your letters, ie with your numbers.

Well, the numbers between 000 and 999 are all possible combinations, right ?

So :

1°) Loop the numbers 0 -&gt; 999
2°) Turn them into a string using <font color=blue>CStr</font color=blue> of 3 characters
3°) Use the <font color=blue>Mid</font color=blue> function to check if char1 = char2 or char1 = char3 or char2 = char3
4°) If one of these is true, continue the loop, if not, store the number in a new array
5°) When your loop is done, take your new array, with the correct strings in it, and replace the characters with the letters of your first array

Done !

Hope it makes sense, now I did half of your homework anyway ;)

<font color=green>Do or do not
There is no try</font color=green>

Ad1
10-08-2001, 04:08 AM
arrays are very useful for cutting down on the amount of code you need, for example if you wanted to check that the sixth letter you created was not the same as the others then instead of putting
<pre><font color=blue>If</font color=blue> Number = intFirst <font color=blue>Then</font color=blue>
MsgBox "duplicate"
<font color=blue>ElseIf</font color=blue> Number = inSecond <font color=blue>Then</font color=blue>
MsgBox "duplicate"
<font color=blue>ElseIf</font color=blue> Number = intThird <font color=blue>Then</font color=blue>
MsgBox "duplicate"
<font color=blue>ElseIf</font color=blue> Number = intFourth <font color=blue>Then</font color=blue>
MsgBox "duplicate"
<font color=blue>ElseIf</font color=blue> Number = intFifth <font color=blue>Then</font color=blue>
MsgBox "duplicate"
<font color=blue>End If</font color=blue></pre>
you could write
<pre><font color=blue>For</font color=blue> X = 1 <font color=blue>To</font color=blue> 5
<font color=blue>If</font color=blue> Number = intNum(X) <font color=blue>Then</font color=blue>
MsgBox "duplicate"
<font color=blue>End If</font color=blue>
<font color=blue>Next</font color=blue> X</pre>
to declare your array put
<pre><font color=blue>Dim</font color=blue> intNum(1 <font color=blue>To</font color=blue> 5) <font color=blue>As Integer</font color=blue></pre>
this becomes even more useful when you have to check hundreds or even thousands of numbers

Wizzard
10-08-2001, 05:15 AM
thnx for the help yoda:)

it's a big homework i'm new in the school i only worked i few times with vb but know i understand it.
thnx alot!

greetz
Wizzard

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum