![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| | Vista - Ascii |
| |
| 12-01-2008 | #1 |
| | 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 Specs |
| 12-01-2008 | #2 |
| | 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: Quote: > 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 Specs |
![]() |
| Thread Tools | |
| |
| Similar Threads for: Ascii | ||||
| Thread | Forum | |||
| 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 | |||
| Finding the ascii code of a non-printable. | VB Script | |||
| When non-ASCII creeps into script | PowerShell | |||