1.    01 Dec 2008 #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.    01 Dec 2008 #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


Similar Threads
Thread Forum
Printing Ascii and non-Ascii codes
Can powershell list the ascii codes and non-ascii codes ?
PowerShell
Unicode or ASCII
If you want the output of a PowerShell command to be produced in ASCII encoding from a simple output redirection operator like >, you can use an...
PowerShell
How to tell SED to emit output in 8-bit ASCII only?
I am sure there are better places/forums to ask the below question, but I didn't find any. If you know a better place please advise! I have to...
Vista file management
Re: ASCII or TBCP
That's just a complain to Apple .... doesn't give me any background on the protocols .... Trust me I do my homework before I come here .... ...
Vista print fax & scan
Finding the ascii code of a non-printable.
I was just reading "Today's Word", an email from joelosteen.com, and noticed "unprintables" (that seemed to be replacing the quote characters); so,...
VB Script
default for out-file -encoding ascii
Hi, I use PowerShell to write batch files for execution. As a result, I need to make sure they are ascii files or they will not execute. I use...
PowerShell
When non-ASCII creeps into script
What to do, what to do... When non-ASCII characters creep into a script, what's the best way to see them and remove them? Without re-typing the...
PowerShell

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • PC Help Forum
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 12:00.
    .