Issue in random password generater code

syntax

#1

Hello

I want ot generate the random password(contains 3 upper case letter and 3 lower case letter along with two number) using the below code.

*i am genrating on one number which later use as ASCII for upper case letter
int val = new Random().Next(26,52)

Here i am generating the character for that generated random number.
string strPwdString = strPwdString +(Char)(‘a’ + val)

But there the code is giving comile time error states that '. '(dot) expected . (+(Char)(‘a’ + val).

Could you please help to resolve this issue.


#2

@Suchi3190,

Correcting your code a bit,

String strPwdString = strPwdString + Convert.ToString(CChar(“a”)+Chr(val))

where val should be a Integer

Regards,
Dominic :slight_smile:


#4

I used your code but its giving same output as “a” everytime. :frowning:


#5

@Suchi3190, Let me exemplify what I have done,

  1. Hardcoded integer val as 99
    It gave me an output ac

  2. Hardcoded integer val as 68
    It gave me an output aD

Regards,
Dominic :slight_smile:


#6

tried your requirement, you can use if you need.

pwGen.xaml (8.0 KB)