掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Long型をULONG型に変換したい (ID:81868)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ULONG型を使用するアプリにデータを転送したいため 下記のようにプログラミングしましたが Chr()で表示できないバイナリ値の場合、 szULONGには正しい数値が入りません。 lnLng=5000 の場合 szULONG= 88 13 00 00 の形式で 入ってきて欲しいのですが 00 13 00 00 となります。 どなたか教えてください。 ※ちなみにデータ転送はString型でないと送れないため szULONGは他型で定義出来ません。 Function Lng_to_ULONG(lnLng As Long) Dim szStr As String * 8 Dim szHex(4) As String * 2 Dim szULONG As String * 4 Dim nValue(4) As Integer Dim I, n As Integer Dim nDigit As Integer Dim n16 As Long 'Longを16進に変換し、2バイトづつに分ける RSet szStr = Hex(lnLng) szHex(1) = Mid(szStr, 7, 2) szHex(2) = Mid(szStr, 5, 2) szHex(3) = Mid(szStr, 3, 2) szHex(4) = Mid(szStr, 1, 2) '16進を10進(Long)に変換する。 For n = 4 To 1 Step -1 n16 = 1 For I = 2 To 1 Step -1 If Trim(Mid(szHex(n), I, 1)) <> "" Then If Asc(Mid(szHex(n), I, 1)) >= Asc("A") Then nDigit = Asc(Mid(szHex(n), I, 1)) - Asc("A") + 10 Else nDigit = Asc(Mid(szHex(n), I, 1)) - Asc("0") End If nValue(n) = nValue(n) + n16 * nDigit End If n16 = 16 * n16 Next I Next n szULONG = Chr(nValue(1)) & Chr(nValue(2)) & Chr(nValue(3)) & Chr(nValue(4)) End Function
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.