Help with C# to VB.Net ... Please

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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(chars[b % (chars.Length - 1)]); }

My C# to Vb.Net routine converted the line above to be:

result.Append(chars(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 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
chars = a.ToCharArray();
int size = maxSize ;
byte[] data = new byte[1];
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data) ;
size = maxSize ;
data = new byte[size];
crypto.GetNonZeroBytes(data);
StringBuilder result = new StringBuilder(size) ;
foreach(byte b in data )
{ result.Append(chars[b % (chars.Length - 1)]); }
return result.ToString();
}

.



Relevant Pages

  • Re: Read text file to Temp file and apply formating and color chan
    ... I call this routine from the OpenFileDialog; ... public static string LayoutInput ... int txPos; ... int charactersTillPoint; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ctypes & strings
    ... This routine outputs and inputs a symmetric block of bytes, ... original output string ... unsigned char read_write (unsigned char *inputs, unsigned char *outputs, int ...
    (comp.lang.python)
  • Re: Alternatives to "Guid"
    ... but not as "globally unique" as a Guid, you could use code like this: ... private string GetUniqueKey() ... int maxSize = 8; ... int size = maxSize; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help with C# to VB.Net ... Please
    ... Rob Panosh ... private string GetUniqueKey() ... int maxSize = 8; ... int size = maxSize; ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Programmatically update forms in design view
    ... The routine that I am running is done before the creation of an MDE. ... I have a problem with updating a label on multiple forms. ... Dim Erm As String, fm As String, MyDB As Database, rs As Recordset, e As ...
    (microsoft.public.access.forms)