The basic thing we are goin' to do is the following steps:
1) Generating Random characters.
2)Printing them in a picture box.
3) Making them scratched.
(1)Generating Random Characters
NOTE:Make sure that you write "Randomize" Command in the form_load event.
dim fck1,fck2,fck3,fck4 as integer fck1 = Int((91 - 65 + 1) * Rnd + 65) fck3 = Int((91 - 65 + 1) * Rnd + 65) fck2 = Int((123 - 97 + 1) * Rnd + 97) fck4 = Int((123 - 97 + 1) * Rnd + 97) gen1 = Chr(fck1) & Chr(fck2) & Chr(fck3) & Chr(fck4) generated1 = Chr$(fck1) & " " & Chr(fck2) & " " & Chr(fck3) & " " & Chr(fck4)
Explanation : Fck 1,2,3 and 4 are variables for storing ascii code of the character which is generated randomly.
65 to 91 is the ascii code of Capital A-Z
97 to 123 is ascii code of Small(lower case) a-z
so, gen1 will contain a FOUR letter word. This we are using for checking purposes
generated1 is the text to be shown in the picture box...(its used because spaces look nice)
(2)Printing in Picture Box
Picture1.print generated1
(3)Making them scratched(using lines)
For i = 1 To 60 X1 = (3000 * Rnd) + 1 X2 = (3000 * Rnd) + 1 x3 = (3000 * Rnd) + 1 x4 = (3000 * Rnd) + 1 Y1 = (3000 * Rnd) + 1 Y2 = (3000 * Rnd) + 1 y3 = (3000 * Rnd) + 1 y4 = (3000 * Rnd) + 1 z1 = (3000 * Rnd) + 1 z2 = (3000 * Rnd) + 1 z3 = (3000 * Rnd) + 1 z4 = (3000 * Rnd) + 1 a1 = (3000 * Rnd) + 1 a2 = (3000 * Rnd) + 1 a3 = (3000 * Rnd) + 1 a4 = (3000 * Rnd) + 1 b1 = (3000 * Rnd) + 1 b3 = (3000 * Rnd) + 1 b2 = (3000 * Rnd) + 1 b4 = (3000 * Rnd) + 1 Picture1.Line (X1, X2)-(x3, x4), vbWhite Picture1.Line (Y1, Y2)-(y3, y4), vbWhite Picture1.Line (z1, z2)-(z3, z4), vbWhite Picture1.Line (a1, a2)-(a3, a4), vbWhite Picture1.Line (b1, b2)-(b3, b4), vbWhite Next i
Explanation : In the variables a1234, b1234, z1234,x1234,y1234 we are genrating a number between 1 to 3000(Because 3000x3000 is dimension of picture box). These are the req. coordinates.
Now we just simply print the lines in the the picture box with these coordinates.
NOTE : To increase the intensity of lines, just increase the upper bound of loop.
The result printed will be Four letters with some(or more) scratches, hardly readable.
Validation Part
If Text1.Text = gen1 Then
MsgBox ("correct")
Else
MsgBox ("wrong")
End If
I hope this helped






MultiQuote




|