例:
VB側
日付データ11月26日 月(0x11) 日(0x26) のバイナリ2バイトデータをVC側の関数に渡す。
VC側
すると、日付(26NOV)のように5バイトのキャラクタ型に変換して戻す。
その時、VC側から受けたキャラクタ型データをVB側でBYTE型に変換するにはどうすればよいか?
説明不足は随時お答えします。宜しくお願いします。
VBのString文字列をバイト配列に変換する方法がわからないということ?
VCのキャラ型データをVBでByte型に変換する方法です。
そんなことできないのでしょうか?
VCのキャラ型データをうける関数のVBの宣言部分はどうなっているのですか?
'バイナリ2バイト表記の日付データを5バイト(01JAN)表記へ変更する
【宣言】
Private Declare Function ChangeDate Lib "ApFunc" ( _
ByVal lpDate2 As String, _
ByVal lpDate7 As String) As Integer
【機能】
Public Function GetChangeDate( _
ByRef byDate() As Byte, _
ByRef intLength As Integer _
) As Boolean
Dim a_strDate7 As String * 8 '7バイト固定長(日付データ 11NOV04 ) + 1バイトのNULL = 計8バイト
Dim byDate2 As Byte
'返却値の異常チェック
a_intRet = JAL_ChangeDateFormat(byDate(), a_strDate7)
If a_intRet <> 0 Then '0:正常/-1:異常
GoTo ERROR_PROC
End If
お願いします。
間違えました。
'バイナリ2バイト表記の日付データを5バイト(01JAN)表記へ変更する
【宣言】
Private Declare Function ChangeDate Lib "ApFunc" ( _
ByVal lpDate2 As String, _
ByVal lpDate7 As String) As Integer
【機能】
Public Function GetChangeDate( _
ByRef byDate() As Byte, _
ByRef intLength As Integer _
) As Boolean
Dim a_strDate7 As String * 8 '7バイト固定長(日付データ 11NOV04 ) + 1バイトのNULL = 計8バイト
Dim byDate2 As Byte
'返却値の異常チェック
a_intRet = ChangeDate(byDate(), a_strDate7)
If a_intRet <> 0 Then '0:正常/-1:異常
GoTo ERROR_PROC
End If
お願いします。
また間違えました。
【宣言】
Private Declare Function ChangeDateFormat Lib "ApFunc" ( _
ByVal lpDate2 As String, _
ByVal lpDate7 As String) As Integer
*****************************************************************
【機能】
Public Function GetChangeDate( _
ByRef byDate() As Byte, _
ByRef intLength As Integer, _
ByRef strAirportPath As String _
) As Boolean
Dim a_strDate7 As String * 8 '7バイト固定長(日付データ (Ex):11NOV04) + 1バイトのNULL = 計8バイト
Dim byDate2 As Byte
Dim a_intRet As Integer
'返却値の異常チェック
a_intRet = ChangeDateFormat(byDate(), a_strDate7) '日付変換関数を呼出して7バイト表記に変換
If a_intRet <> 0 Then '0:正常/-1:異常
a_strErrLog = "JAL_ChangeDateFormat関数戻り値異常"
GoTo ERROR_PROC
End If
*****************************************************************
お願いします。
またまた間違えました。最終更新です。
【宣言】
Private Declare Function ChangeDateFormat Lib "ApFunc" ( _
ByVal lpDate2 As String, _
ByVal lpDate7 As String) As Integer
*****************************************************************
【機能】
Public Function GetChangeDate( _
ByRef byDate() As Byte, _
ByRef intLength As Integer, _
ByRef strAirportPath As String _
) As Boolean
Dim a_strDate7 As String * 8 '7バイト固定長(日付データ (Ex):11NOV04) + 1バイトのNULL = 計8バイト
Dim byDate2 As Byte
Dim a_intRet As Integer
'返却値の異常チェック
a_intRet = ChangeDateFormat(byDate(), a_strDate7) '日付変換関数を呼出して7バイト表記に変換
If a_intRet <> 0 Then '0:正常/-1:異常
GoTo ERROR_PROC
End If
*****************************************************************
お願いします。
a_strDate7のデータをVBのバイト配列に入れたいということですね?
であれば
Dim a() As Byte
Dim a_strDate7 As String * 8
a=strDate7
とすることでバイト配列になります。
VC側の char * にVBの直接バイト型の配列のアドレスを渡すことも可能ですよ。バイト型の固定長配列のみ含む構造体を定義して、それを渡せばOKです。
例:
Type typByteArray
byt As Byte(0 to 5)
End Type
Declare Sub Sample Lib "Sample.dll" (byteArray As typByteArray)
VC++側は
__declspec(dllexport) void WINAPI Sample(char *a)
ツイート | ![]() |