this is my first time asking for help here at StackOverflow.
I've been trying to work on a project which allows random string generation. Although it is working, I'm trying to find out how to add special character(s) after a certain amount of characters that have been generated.
This is my code:
Public Class Form1
Dim pool As String = ""
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
pool = ""
If CheckBox1.Checked = True Then
pool = pool & "0123456789"
End If
If CheckBox2.Checked = True Then
pool = pool & "abcdefghijklmnopqrstuvwxyz"
End If
If CheckBox3.Checked = True Then
pool = pool & "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
End If
Dim count = 1
Result.Text = ""
Dim cc As New Random
Dim strpos = ""
While count <= Length.Text
strpos = cc.Next(0, pool.Length)
Result.Text = Result.Text & pool(strpos)
count = count + 1
End While
End Sub
End Class
Now, I can generate the string, but I'm looking to find out how to add hyphens. For example I get "XikclCwXrPBd8RL35oaoN5LNW" when the string is generated at twenty-five characters. What I can't figure out, is how to add hyphens every fifth character, which it would look like this, "Xikcl-CwXrP-Bd8RL-35oao-N5LNW."
If I were to add code which generates hyphens every fifth (or any custom amount) character, would I have to redo my code again, or is the solution to my problem simple?
Thanks, and I hope this question isn't too much of a hassle.
Here is also a screenshot of my project. http://puu.sh/aEgus/0309527a1e.png I don't have "at least 10 reputation to post images."