hi,
I am doing a project related to encryption in
vb. When i am trying to run it, I am getting an overflow error in the following function at this statement
n = n + (Mid(Binary, (tpp - s + 1), 1) * (2 ^ (s - 1)))
If I made the statement which calls the function as comment, at the very next statement of that statement again, I am getting the same overflow error.
Here i am also specifying the statement which calls function
tp = BinaryToDecimal(hrot)
Can anybody tell why i am getting overflow error?
Public Function BinaryToDecimal(Binary As String) As Long
Dim n As Long
Dim s As Integer
Dim tpp As Integer
tpp = Len(Binary)
For s = 1 To tpp
n = n + (Mid(Binary, (tpp - s + 1), 1) * (2 ^ (s - 1)))
Next s
BinaryToDecimal = n
End Function
Please help me.
Thanks
tulasi