ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Accessing to MsgID property with VB

Post new topic  Reply to topic
 Accessing to MsgID property with VB « View previous topic :: View next topic » 
Author Message
deuspi
PostPosted: Mon Jan 21, 2002 9:48 am    Post subject: Reply with quote

Newbie

Joined: 20 Jan 2002
Posts: 9
Location: Paris, France

Hi there,

I'm currently building an application with VB6. I have to put a message in a queue. Then there will be a COBOL prog that will reply to this message by putting another message in another queue. The reply message will have the original one's MsgID in his CorrelID field, so that I can find my reply with my VB program afterwards.

The problem is that when I send my first message, I want to get the MsgID property in order to use it later, but all I get is a strange string and not the hexadecimal value. I know that the real type of this property is MQBYTE(24) but I really want to get this value in my VB program.

Any help would be greatly appreciated.

Pierre
Back to top
View user's profile Send private message
MillsPerry
PostPosted: Mon Jan 21, 2002 12:50 pm    Post subject: Reply with quote

Acolyte

Joined: 08 Oct 2001
Posts: 59
Location: ZyQuest, inc.

VB has an endearing little habit of truncating a string when it encounters hex Zero (&h00). Since MsgId is a binary field, you stand a good chance of getting truncated. VB programs can get around this problem by using the MsgIdHex property, which contains the hex version of the MsgId.

By the way, I am assuming you are using MQAX200. I dont know whether the old Win32 API has a MsgId Hex field or not. If it doesn't, you might want to consider using the MemCopy API function to copy the MsgId to a byte array.
Back to top
View user's profile Send private message Send e-mail
deuspi
PostPosted: Tue Jan 22, 2002 2:26 am    Post subject: Reply with quote

Newbie

Joined: 20 Jan 2002
Posts: 9
Location: Paris, France

Hi,

Thanks for your help. Unfortunately, I can't find any MsgIDHex property in the MQMD class. So I've just written a little function :

Public Function DecodeID(MsgID As String) As String
Dim IDNum As Integer
Dim temp As String
Dim MsgIDNum As String
Dim i As Integer

For i = 1 To Len(MsgID)
IDNum = Asc(Mid(MsgID, i, 1))
temp = "00" & Hex(IDNum)
MsgIDNum = MsgIDNum & Right(temp, 2)
Next
DecodeID = MsgIDNum
End Function

All I have to do is giving my ASCII ID to this function and I get the Hex ID as a String variable. I hope that will work..

What is MQAX200 ??
I don't understand what you mean with the MemCopy API function, could you explain me where I can find this function and how to use it ?

Thanks a lot for your help.

Pierre
Back to top
View user's profile Send private message
MillsPerry
PostPosted: Tue Jan 22, 2002 8:05 am    Post subject: Reply with quote

Acolyte

Joined: 08 Oct 2001
Posts: 59
Location: ZyQuest, inc.

MQAX200 is the DLL name for MQSeries Automation Objects for ActiveX. This is a slightly more modern way to interact with MQSeries than the old API functions you seem to be using. If you have the MQ client installed on your PC, then you should have the documentation for it.

To use it, you set a reference in your VB project to "IBM MQSeries Automation Objects for ActiveX". Then you Dim all your MQ objects as COM objects. For more detail, see the documentation.
Back to top
View user's profile Send private message Send e-mail
MillsPerry
PostPosted: Tue Jan 22, 2002 8:32 am    Post subject: Reply with quote

Acolyte

Joined: 08 Oct 2001
Posts: 59
Location: ZyQuest, inc.

I forgot to mention... CopyMemory is a Win32 API function that can copy data structures and other variables to a byte array. It is declared like this:

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

And used like this:

Sub Rfh2String(ByRef rfhHeader As RFH2, ByRef msg As MQMessage) 'As String void
' ==========================================================================
' Purpose: Convert an RFH2 structure into a string.
'
' 1. Define a byte array with the same length as the RFH2 structure.
'
' 2. Use CopyMemory to map the structure to the array. Note, VB blows up
' if you try to do this directly to a string.
'
' 3. Process the array, copying each byte to the string.
'
' I only blew up VB 5 times, losing a day's worth of work trying to figure
' this out.
' ==========================================================================
Dim intLength As Long
Dim strRFH2 As String
Dim arRFH2() As Byte
Dim i As Long

intLength = Len(rfhHeader)

ReDim arRFH2(intLength)
CopyMemory arRFH2(0), rfhHeader, intLength

strRFH2 = ""
For i = 0 To intLength - 1
strRFH2 = strRFH2 & Chr(arRFH2(i))
Next i
End Sub
Back to top
View user's profile Send private message Send e-mail
deuspi
PostPosted: Tue Jan 22, 2002 8:50 am    Post subject: Reply with quote

Newbie

Joined: 20 Jan 2002
Posts: 9
Location: Paris, France

Thanks for your help.
I'm gonna try this out.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Accessing to MsgID property with VB
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.