Windows Vista Forums

Ascii

  1. #1


    collie Guest

    Ascii

    Can someone please help me translate the following vb.net function to vbscript?




    Code:Public Shared Function EncGuid(ByVal expression As String) As String

    'Function receives GUID for calculate chksum.

    Dim countEvens As Integer = 0

    Dim countASCII As Integer = 0

    Dim chkSum As Integer = 0



    expression = expression.Replace("-", "")



    For i As Integer = 0 To expression.Length - 1

    countASCII = countASCII + Asc(expression.Chars(i))

    If (Integer.Parse(expression.Chars(i),
    System.Globalization.NumberStyles.HexNumber) Mod 2) = 0 Then

    countEvens = countEvens + 1

    End If

    Next



    countASCII = countASCII Mod 1000



    chkSum = countASCII Xor countEvens



    Return chkSum.ToString("000")

    This is what I have so far but i can't seem to get it right:

    Code:Function EncGuid(expression)
    'Function receives GUID for calculate chksum.

    countEvens = 0

    countASCII = 0

    chkSum = 0

    'expression= expression.Replace("-", "")

    expression=Replace(expression,"-","")

    For i = 0 To Len(expression)- 1


      My System SpecsSystem Spec

  2. #2


    collie Guest

    RE: Ascii

    Please note that the expression is a guid and the replace function will
    return something like this:
    1E6FCC590E094B14875C7AC1FD158E6D8651E6FCC590E094B14875C7AC1FD158E6D865.

    I forgot to mention that the expression is a guid.

    "collie" wrote:

    > Can someone please help me translate the following vb.net function to vbscript?
    >
    >
    >
    >
    > Code:Public Shared Function EncGuid(ByVal expression As String) As String
    >
    > 'Function receives GUID for calculate chksum.
    >
    > Dim countEvens As Integer = 0
    >
    > Dim countASCII As Integer = 0
    >
    > Dim chkSum As Integer = 0
    >
    >
    >
    > expression = expression.Replace("-", "")
    >
    >
    >
    > For i As Integer = 0 To expression.Length - 1
    >
    > countASCII = countASCII + Asc(expression.Chars(i))
    >
    > If (Integer.Parse(expression.Chars(i),
    > System.Globalization.NumberStyles.HexNumber) Mod 2) = 0 Then
    >
    > countEvens = countEvens + 1
    >
    > End If
    >
    > Next
    >
    >
    >
    > countASCII = countASCII Mod 1000
    >
    >
    >
    > chkSum = countASCII Xor countEvens
    >
    >
    >
    > Return chkSum.ToString("000")
    >
    > This is what I have so far but i can't seem to get it right:
    >
    > Code:Function EncGuid(expression)
    > 'Function receives GUID for calculate chksum.
    >
    > countEvens = 0
    >
    > countASCII = 0
    >
    > chkSum = 0
    >
    > 'expression= expression.Replace("-", "")
    >
    > expression=Replace(expression,"-","")
    >
    > For i = 0 To Len(expression)- 1
    >

      My System SpecsSystem Spec


Ascii
Similar Threads
Thread Forum
Printing Ascii and non-Ascii codes PowerShell
Unicode or ASCII PowerShell
How to tell SED to emit output in 8-bit ASCII only? Vista file management
Re: ASCII or TBCP Vista print fax & scan
When non-ASCII creeps into script PowerShell