Hi,
I'm creating password with track bar.
I do not know how to write code (TrackBar.Value):
Please check my code:
01.
int
PassLength = 0;
02.
static
string
Shuffle(
string
input)
03.
{
04.
var q = from c
in
input.ToCharArray()
05.
orderby Guid.NewGuid()
06.
select c;
07.
string
s =
string
.Empty;
08.
foreach
(var r
in
q)
09.
s += r;
10.
return
s;
11.
}
12.
private
void
CreatePassword_Click(
object
sender, EventArgs e)
13.
{
14.
txt_CreatePass.Text =
""
;
15.
string
text =
"aAbBcCdDeEfFgGhHiIjJhHkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ01234567890123456789{,;:!*$@-_=^[}{,;:!*$@-_=^[}"
;
16.
text = Shuffle(text);
//shuffle the above symbols using shuffle() method.
17.
text = text.Remove(PassLength);
//cut the string size according to the chosen trackbar value.
18.
txt_CreatePass.Text = text;
19.
}
20.
21.
private
void
TrackBar_ValueChanged(
object
sender, EventArgs e)
22.
{
23.
24.
this
.TrackBarCreatePass.Value = Convert.ToInt32(+1);
25.
lbl_Count.Text = PassLength.ToString();
26.
27.
//lbl_Count.Text = TrackBarCreatePass.Value.ToString();
28.
//PassLength = this.TrackBarCreatePass.Value;
29.
}
30.
31.
private
void
TrackBar1_CreatePass_ValueChanged(
object
sender, EventArgs e)
32.
{
33.
PassLength = TrackBar1_CreatePass.Value + 1;
//trackbar value starts from 0, so I add +1 to make it understandable;
34.
lbl_Count.Text = PassLength.ToString();
35.
}