I am trying to convert the following C# routine (below) to Vb.Net. I
am having troubles with the following line of code
{ result.Append(c hars[b % (chars.Length - 1)]); }
My C# to Vb.Net routine converted the line above to be:
result.Append(c hars(b % (chars.Length - 1)))
But I am getting error "Character is not Valid" on the "%".
Any help would be appreciated.
Cheers,
Rob Panosh
Advanced Software Designs
private string GetUniqueKey()
{
int maxSize = 8 ;
int minSize = 5 ;
char[] chars = new char[62];
string a;
a = "abcdefghijklmn opqrstuvwxyzABC DEFGHIJKLMNOPQR STUVWXYZ1234567 890";
chars = a.ToCharArray() ;
int size = maxSize ;
byte[] data = new byte[1];
RNGCryptoServic eProvider crypto = new RNGCryptoServic eProvider();
crypto.GetNonZe roBytes(data) ;
size = maxSize ;
data = new byte[size];
crypto.GetNonZe roBytes(data);
StringBuilder result = new StringBuilder(s ize) ;
foreach(byte b in data )
{ result.Append(c hars[b % (chars.Length - 1)]); }
return result.ToString ();
}
am having troubles with the following line of code
{ result.Append(c hars[b % (chars.Length - 1)]); }
My C# to Vb.Net routine converted the line above to be:
result.Append(c hars(b % (chars.Length - 1)))
But I am getting error "Character is not Valid" on the "%".
Any help would be appreciated.
Cheers,
Rob Panosh
Advanced Software Designs
private string GetUniqueKey()
{
int maxSize = 8 ;
int minSize = 5 ;
char[] chars = new char[62];
string a;
a = "abcdefghijklmn opqrstuvwxyzABC DEFGHIJKLMNOPQR STUVWXYZ1234567 890";
chars = a.ToCharArray() ;
int size = maxSize ;
byte[] data = new byte[1];
RNGCryptoServic eProvider crypto = new RNGCryptoServic eProvider();
crypto.GetNonZe roBytes(data) ;
size = maxSize ;
data = new byte[size];
crypto.GetNonZe roBytes(data);
StringBuilder result = new StringBuilder(s ize) ;
foreach(byte b in data )
{ result.Append(c hars[b % (chars.Length - 1)]); }
return result.ToString ();
}
Comment