Coding in Visual Basic

Information to consider when coding IBM® MQ programs in Microsoft Visual Basic. Visual Basic is supported only on Windows.

Note: From IBM WebSphere® MQ 7.0, outside the .NET environment, support for Visual Basic (VB) has been stabilized at the IBM WebSphere MQ 6.0 level. Most new function added to IBM WebSphere MQ 7.0 or later is not available to VB applications. If you are programming in VB.NET, use the IBM MQ classes for .NET. For more information, see Developing .NET applications.

[V9.0.0.0 Jun 2016]From IBM MQ 9.0, support for Microsoft Visual Basic 6.0 is deprecated. IBM MQ classes for .NET are the recommended replacement technology.

To avoid unintended translation of binary data passing between Visual Basic and IBM MQ, use an MQBYTE definition instead of MQSTRING. CMQB.BAS defines several new MQBYTE types that are equivalent to a C byte definition and uses these within IBM MQ structures. For example, for the MQMD (message descriptor) structure, MsgId (message identifier) is defined as MQBYTE24.

Visual Basic does not have a pointer data type, so references to other IBM MQ data structures are by offset rather than pointer. Declare a compound structure consisting of the two component structures, and specify the compound structure on the call. IBM MQ support for Visual Basic provides an MQCONNXAny call to make this possible and allow client applications to specify the channel properties on a client connection. It accepts an untyped structure (MQCNOCD) in place of the typical MQCNO structure.

The MQCNOCD structure is a compound structure consisting of an MQCNO followed by an MQCD. This structure is declared in the exits header file CMQXB. Use the routine MQCNOCD_DEFAULTS to initialize an MQCNOCD structure. A sample making MQCONNX calls is provided (amqscnxb.vbp).

MQCONNXAny has the same parameters as MQCONNX, except that the ConnectOpts parameter is declared as being of Any data type rather than of MQCNO data type. This allows the function to accept either the MQCNO or the MQCNOCD structure. This function is declared in the main header file CMQB.