Dear Friends,
i am new in vb.net, still i am learning .net, here i attach a simple code written by me, from so many references.
basically this programme generate code from particular string i already set my particular string, you can try other string also my stirng is "RGZCCW3P2EJBC3G352ZB", i request all senior programmer of .net kindly solve my issue and complete this programme. i try many times from other reference but not success. so make this programme full and kindly post here as a reply. thats i learn further.
thanks
my problem can't find result, it alwasy show null, surely i mistake some where which i can't trace, so i request you complete this and post full code here.
Private Function bincode(ByVal st As String) As String
Dim result As String
Try
Dim str As String = ""
Select Case st
Case "2"
str = "00000"
Case "3"
str = "00001"
Case "4"
str = "00010"
Case "5"
str = "00011"
Case "6"
str = "00100"
Case "7"
str = "00101"
Case "8"
str = "00110"
Case "9"
str = "00111"
Case "A"
str = "01000"
Case "B"
str = "01001"
Case "C"
str = "01010"
Case "D"
str = "01011"
Case "E"
str = "01100"
Case "F"
str = "01101"
Case "G"
str = "01110"
Case "H"
str = "01111"
Case "J"
str = "10000"
Case "K"
str = "10001"
Case "L"
str = "10010"
Case "M"
str = "10011"
Case "N"
str = "10100"
Case "P"
str = "10101"
Case "Q"
str = "10110"
Case "R"
str = "10111"
Case "S"
str = "11000"
Case "T"
str = "11001"
Case "U"
str = "11010"
Case "V"
str = "11011"
Case "W"
str = "11100"
Case "X"
str = "11101"
Case "Y"
str = "11110"
Case "Z"
str = "11111"
End Select
result = str
Catch exception As Exception
result = ""
End Try
Return result
End Function
Private Function toobinary(ByVal st As String) As String
Dim result As String
Try
Dim str As String = ""
While st.Length <> 0
Dim str2 As String = st(0).ToString()
str += bincode(str2)
st = st.Substring(1)
End While
result = str
Catch exception As Exception
result = ""
End Try
Return result
End Function
Public Function DecryptString(ByVal [me] As ULong) As ULong
Dim result As ULong
Try
Dim num As ULong = [me] Mod 10UL
[me] /= 10UL
Dim num2 As ULong = 0UL
While [me] <> 0UL
Dim num3 As ULong = [me] Mod 10UL
If num3 < num Then
num3 += 10UL
End If
Dim num4 As ULong = num3 - num
num2 = num2 * 10UL + num4
[me] /= 10UL
End While
result = num2
Catch exception As Exception
result = 0UL
End Try
Return result
End Function
Public Function toodec(ByVal st As String) As ULong
Dim result As ULong
Try
Dim str As String = toobinary(st)
Dim num As ULong = 0UL
Dim i As Integer = 0
While str.Length <> 0
Dim num2 As ULong = Convert.ToUInt64(str(str.Length - 1)) - 48UL
num += num2 * CULng(Math.Pow(2.0, CDec(i)))
str = str.Substring(0, str.Length - 1)
i += 1
End While
result = num
Catch exception As Exception
result = 0UL
End Try
Return result
End Function
Public Function [date](ByVal st As String) As Integer
Dim result
Try
Dim num As ULong = toodec(st)
num = DecryptString(num)
Dim hashCode As Integer = "RGZCCW3P2EJBC3G352ZB".GetHashCode
If hashCode < 0 Then
hashCode *= -1
End If
Dim i2 As Int64 = 103287435787683895
Dim l As Long = CLng(hashCode)
l = l * 100000000L
Dim ul As ULong = CULng(l)
ul = ul - num
Dim I As Integer = CInt(ul)
result = I
'result = CInt((num - CULng((CLng(hashCode) * 100000000L))))
Catch exception As Exception
result = 0
End Try
Return result
End Function
|