473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Marshal an Array with Fix lenght?

3
Hi,
I need an array with fix String lenghts and fix rows...

I do this...

=========================================
Imports System.Runtime.InteropServices
Public Class Class1
Public WPFFunktion As String
Public WPFFeld1 As String
Public WPFFeld2 As String
Public WPFFeld3 As String
Public WPFFeld4 As String
Public WPFFeld5 As String
Public WPFInfo As String

<StructLayout(LayoutKind.Sequential)> Public Structure MYSATZ

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public FUNKTION As String
<MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPWStr, SizeConst:=5)> Public TABELLE1() As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public Info As String

End Structure

' Cobol Dll laden...
' ==================
Declare Function CALLMYFUNKTION Lib "CALLMY" (ByRef VARIADATEN As MYSATZ) As Integer

Public Sub MyCallProg()

' Statusfeld aus Cobol
Dim CblStatus As Integer

' Datenbereich erstellen
Dim MYSATZSATZ001 = New MYSATZ

' Daten vom Hauptprogramm in Linkage Bereich übertragen


' Standard Felder
MYSATZSATZ001.FUNKTION = WPFFunktion
MYSATZSATZ001.TABELLE1(1) = WPFFeld1
MYSATZSATZ001.TABELLE1(2) = WPFFeld2
MYSATZSATZ001.TABELLE1(3) = WPFFeld3
MYSATZSATZ001.TABELLE1(4) = WPFFeld4
MYSATZSATZ001.TABELLE1(5) = WPFFeld5
MYSATZSATZ001.Info = WPFInfo

' Cobol Programm aufrufen mit gefüllter Linkage...
CblStatus = CALLMYFUNKTION(MYSATZSATZ001)

' Standard Felder
WPFFunktion = MYSATZSATZ001.FUNKTION.Trim(" ")
WPFFeld1 = MYSATZSATZ001.TABELLE1(1).Trim(" ")
WPFFeld2 = MYSATZSATZ001.TABELLE1(2).Trim(" ")
WPFFeld3 = MYSATZSATZ001.TABELLE1(3).Trim(" ")
WPFFeld4 = MYSATZSATZ001.TABELLE1(4).Trim(" ")
WPFFeld5 = MYSATZSATZ001.TABELLE1(5).Trim(" ")
WPFInfo = MYSATZSATZ001.Info.Trim(" ")

End Sub

End Class

=========================================

But it will not work...

For this I need an array with:

One WPFField with 10 Characters (String)
And 5 Rows (5 Times WPFField)

What is wrong?

Best Regrads

Bernd
Feb 20 '12 #1
1 1284
Berndr
3
It is now working...
Feb 21 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Prabhu | last post by:
Hi, I have to send a structure through TCPClient socket. we can send only byte array through the socket, So please any one can help me by telling How to convert a struct object into an byte...
4
by: Peter | last post by:
Hi, I want to use an array str, while each array element str is an array of chars of fixed length, say 40; The best way to handle this in C# is StringBuilder I guess, but as legacy C++ code...
5
by: Robin Tucker | last post by:
I need to marshal an IntPtr (which I've got from GlobalLock of an HGLOBAL) into a byte array. I know the size of the array required and I've got a pointer to the blob, but I can't see how to copy...
0
by: verpeter | last post by:
When try pass only one delegate as parameter, all work fine. But I need call function, that take as parameter array of function pointers. From C++ code I used such code: static void* aFuncPtrs =...
6
by: Fla | last post by:
Hi! I would like to use Compression namespace for Array, i.e. use .NET native Compression for compress a String, or an Array of Integer whose elements are returned values of AscW for each char of...
12
by: xla76 | last post by:
I have a function that returns an array of string values, occasionally the returned array value is 'Nothing' I need to check if the value is nothing before moving on - how can I do this - none of...
0
by: ambeer | last post by:
Hello, i have created the struct: #region PacketStructures struct MainPacket { HeaderData headerData; public byte moduleType; ...
10
by: Scott Townsend | last post by:
So I need to talk to a devices that expects all of the bits and bytes I sent it to be in specific places (not yet 100% defined). I wanted to create a structure/class with all of the data in it...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
3
by: ramesnagaram | last post by:
Hi , i want to how array.lengh is implemented in java. i didn't find lengh method in Object class or in any other classes. with regards ramesh
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.