Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 and MF Cobol

Status
Not open for further replies.

x107951

Programmer
Jun 17, 2002
5
US
I have a VB4 app that makes a call to a mf cobol dll and returns some values. I now have migrated my VB4 to VB6 and when I make the call I'm getting incorrect values returned?? Does anyone have any solutions?? This is really urgent??
 
Without looking at your code, I can only make educated guesses.

Off the top of my head, VB4 and VB6 have a difference in certain data type alignments. Consider the following:

Option Explicit
Type MyType
l as Long
i as Integer
End Type

The size of MyType is 6 in VB4 and 8 in VB6. VB6 adds padding at the end of Long, because the space Long occupies must be a multiple of the Long data type. Also, Long starts at a byte that is a multiple of Long (4), and Integer starts at a byte that is a multiple of Integer (2).
 
This is my UDT in VB

Type typMiscInputCbl
strStatusVal As String * 24
intInterruptFlag As Integer
intTranCnt As Integer
intAttAge477Flag As Integer
strCallFromVBFlag As String * 1
strBasicFiller As String * 27
End Type

And I have the following in COBOL

01 VB-MISC-DATA.
05 VB-STATUS PIC X(24).
05 VB-INTERRUPT-FLAG PIC S9(4) COMP-5.
05 VB-TRAN-CNT PIC S9(4) COMP-5.
05 VB-ATT-AGE-477-FLAG PIC S9(4) COMP-5.
05 VB-CALL-FROM-VB-FLAG PIC X.
05 FILLER PIC X(27).

Do I have to allow for the extra padding in the COBOL??

Thanks In Advance.
 
What kind of incorrect values do you receive?
How do you send the UDT to COBOL (Function Declaration, ByVal, etc..)?
What does the PROCEDURE DIVISION statement say (in COBOL)?
Are the call to COBOL, the UDT and the COBOL code untouched when migrating to vb6?

Dimandja

 
Incorrect figures (calculations) returned from the cobol...
One of the firgures should read -57.01 coming back in VB6 with -17.99

I call the UDT as follows..

Public MIS As typMiscInputCbl
Public DEF As typDefInputCbl
Public BIC As typBasicInputCbl

Call CALCTRAN(MIS, DEF, BIC)

My procedure division has the following..
ENTRY "CALCTRAN" pascal32 USING VB-MISC-DATA
VB-DEFICIENCY-DATA
VB-BASIC-DATA.
entry trace.

This is my UDT in COBOL

01 VB-MISC-DATA.
05 VB-STATUS PIC X(24).
05 VB-INTERRUPT-FLAG PIC S9(4) COMP-5.
05 VB-TRAN-CNT PIC S9(4) COMP-5.
05 VB-ATT-AGE-477-FLAG PIC S9(4) COMP-5.
05 VB-CALL-FROM-VB-FLAG PIC X.
05 FILLER PIC X(27).


All code has been untouched in the migration....
 
Try to use the following code to find out the real length of your UDT (this should show if any padding occurs):

Dim udtLength As typMiscInputCbl
MsgBox LenB(udtLength)

It is also possible that Win32 environments such as Windows 98 and Windows NT, strings are Unicode (each character using 2 bytes of memory). Has the machine or OS changed during the upgrade?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top