close

數字型態與Bytes 的互轉



Public Class Form1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' 數字轉成 Bytes
Dim iCountS As Single = 45.11
Dim iCountD As Double = 45.11 ' single 相當於 float 是4個Byte
Dim byInputDataS = BitConverter.GetBytes(iCountS)
Dim byInputDataD = BitConverter.GetBytes(iCountD)


'Bytes 轉成數字
Dim iCountSS = BitConverter.ToSingle(byInputDataS, 0)
' Dim iCountDD = BitConverter.ToSingle(byInputDataD, 0) '跟原本型態不合 轉換後會數值錯掉
Dim iCountDD = BitConverter.ToDouble(byInputDataD, 0)


MsgBox(iCountSS)


End Sub
End Class

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 prague12 的頭像
    prague12

    prague12

    prague12 發表在 痞客邦 留言(0) 人氣()