hi guys, im new to this forum and beginner to c# too
i had a code to generate key in vb.net, bt for sm reasons i switched to c# and need to convert vb.net coding to c#
I converted it online, bt it doesnt work for me : Please have a look on coding
I think the problem is of ASC and HEX, which c# does not recognize. Hope i will get its solution here.
Regards and Thanks in advance
i had a code to generate key in vb.net, bt for sm reasons i switched to c# and need to convert vb.net coding to c#
I converted it online, bt it doesnt work for me : Please have a look on coding
C#:
Public Function GenCode(ByVal strUN As String) As String
Dim P1 As Long, P2 As Long, P3 As Long
Dim S1 As String, S2 As String, S3 As String
Dim j As Integer
For j = 1 To Len(strUN)
P1 = P1 + Asc(Mid(strUN, j, 1)) * 15
Next
strUN = LCase(strUN)
For j = 1 To Len(strUN)
P2 = P2 + Asc(Mid(strUN, j, 1)) * 20
Next
strUN = UCase(strUN)
For j = 1 To Len(strUN)
P3 = P3 + Asc(Mid(strUN, j, 1)) * 25
Next
S1 = CStr(Hex(P1))
S2 = CStr(Hex(P2))
S3 = CStr(Hex(P3))
If Len(S1) > 4 Then S1 = Left(S1, 4)
If Len(S2) > 4 Then S2 = Left(S2, 4)
If Len(S3) > 4 Then S3 = Left(S3, 4)
GenCode = S1 & "-" & S2 & "-" & S3
End Function
I think the problem is of ASC and HEX, which c# does not recognize. Hope i will get its solution here.
Regards and Thanks in advance