You might also want tp analyse the code by using the debugger, if you are not sure what it does. The debugger allows you to execute the code step by step and to inspect the values of variables as the code executes.
–
Olivier Jacot-DescombesDec 26 '11 at 20:49

It actually works but it use MessageBox instead of Console.Writeline. How can I use the variable result in Label?
–
boom_box87Dec 26 '11 at 22:22

Supposedly the variable 'result' should be display on label.text property. So what I did is Label1.Text = result But for some reason since it is under the for-loop, it already displayed all the characters. Is there any additional code provided by Olivier that will just activate only by clicking the button once, then reveal the character (i.e, string "ABAC" will reaveal "-B--" after clicking a button) Great thanks to Olivier Jacot-Descombes for the code he provided.
–
boom_box87Dec 27 '11 at 13:20

You have to separate the code into three parts. 1: Variables, which must be available during the whole process, must be placed in the header. 2: They must be initialized in Form_Load (or when the template text changes). 3: Finally, there is the Button_Click code, which is executed at each click, of cause without loop, since you are performing the loop manually, by clicking the button several times. I changed the example.
–
Olivier Jacot-DescombesDec 27 '11 at 14:49

I have already posted an answer where I focused on the algorithm. The algorithm code was directly integrated into a form. This works but is not a good practice. The code would be more reusable, more understandable and could be tested more easily if it was extracted to a separate class.

We can test the class like this in a little console application, without a form:

Module Programm
Public Sub Main()
Dim revealer = New RandomTextRevealer("Just a test")
Console.WriteLine(revealer.HiddenText)
For i As Integer = 1 To 12
Console.WriteLine(revealer.RevealNext())
Next
Console.ReadKey()
End Sub
End Module

Now we can integrate it in a form like this (I added a Reset-button, in order to be able to repeat the test with different random values):