16,554
社区成员
发帖
与我相关
我的任务
分享
Public Overloads Shared Sub Byte2Decimal(ByRef intResult As Integer, ByVal byteSource() As Byte, ByVal iStrIndex As Integer, ByVal iEndIndex As Integer, Optional ByVal blnHighFront As Boolean = True)
Dim strResult As String = String.Empty
Byte2DecimalBase(strResult, byteSource, iStrIndex, iEndIndex, blnHighFront)
If IsNumeric(strResult) Then
intResult = CInt(strResult)
Else
intResult = 0
End If
End Sub
Public Overloads Shared Sub Byte2Decimal(ByRef lngResult As Long, ByVal byteSource() As Byte, ByVal iStrIndex As Integer, ByVal iEndIndex As Integer, Optional ByVal blnHighFront As Boolean = True)
Dim strResult As String = String.Empty
Byte2DecimalBase(strResult, byteSource, iStrIndex, iEndIndex, blnHighFront)
If IsNumeric(strResult) Then
lngResult = CLng(strResult)
Else
lngResult = 0
End If
End Sub
Private Shared Sub Byte2DecimalBase(ByRef strResult As String, ByVal byteSource() As Byte, ByVal iStrIndex As Integer, ByVal iEndIndex As Integer, Optional ByVal blnHighFront As Boolean = True)
If iEndIndex >= iStrIndex Then
Dim sTmp As String = String.Empty
Dim sResult As String = String.Empty
Dim I As Integer
If blnHighFront Then
For I = iStrIndex To iEndIndex
sTmp = Hex(byteSource(I))
sTmp = StrDup(2 - sTmp.Length, "0") & sTmp
sResult = sResult & sTmp
Next
Else
For I = iEndIndex To iStrIndex Step -1
sTmp = Hex(byteSource(I))
sTmp = StrDup(2 - sTmp.Length, "0") & sTmp
sResult = sResult & sTmp
Next
End If
strResult = CLng("&H" & sResult).ToString
sTmp = Nothing
sResult = Nothing
I = Nothing
Else
strResult = "0"
End If
End Sub