Click here to Skip to main content
16,005,734 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionNeed help getting values from a form Pin
darkchronos22-Nov-06 4:31
darkchronos22-Nov-06 4:31 
AnswerRe: Need help getting values from a form Pin
Taylor Kobani22-Nov-06 21:10
Taylor Kobani22-Nov-06 21:10 
Questionevent log Listener Pin
ONeil Tomlinson22-Nov-06 4:13
ONeil Tomlinson22-Nov-06 4:13 
AnswerRe: event log Listener Pin
Johan Hakkesteegt26-Nov-06 22:21
Johan Hakkesteegt26-Nov-06 22:21 
QuestionHelp using control collection Pin
Magno R. Vasquez22-Nov-06 3:48
Magno R. Vasquez22-Nov-06 3:48 
GeneralRe: Help using control collection Pin
hollywood_t22-Nov-06 4:14
hollywood_t22-Nov-06 4:14 
AnswerRe: Help using control collection Pin
hollywood_t24-Nov-06 5:41
hollywood_t24-Nov-06 5:41 
QuestionMarshal arrays of strings - how to? Pin
marccp22-Nov-06 3:45
marccp22-Nov-06 3:45 
I have problem with accessing arrays of strings.

Below is a VB.NET code of function StructToByteArray, which is modified version of http://www.codeproject.com/useritems/readwritestructstobinfile.asp

'This function copys the structure data into a byte()
Private Function StructToByteArray(ByVal strukt As Object) As Byte()

Try

Dim buffer(Marshal.SizeOf(strukt)) As Byte

'Allocate the buffer to memory and pin it so that GC cannot use the space (Disable GC)
Dim h As GCHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned)

'copy the struct into int byte() mem alloc
Marshal.StructureToPtr(strukt, h.AddrOfPinnedObject(), False)

h.Free() 'Allow GC to do its job

Return buffer ' return the byte(). After all thats why we are here right.

Catch ex As Exception
BladPokaz(ex)
Return Nothing
End Try
End Function


And here are the sample structure:


<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Private Structure Str1

Friend dintVal As Integer

<MarshalAs(UnmanagedType.ByValArray, SizeConst:=10)> _
Friend dintArr() As Integer

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=6)> _
Friend stringVal As String

End Structure


What we've got here is Integer value, array of Integer values and a String value.

The problem is how to define an array of Strings. The size of array
and size of String could be fixed.

I've tried other array types (SafeArray, ByValTStr, etc.) and define ArraySubType.
None of this worked for me.

Thanks in advance for your help.

Marc
AnswerRe: Marshal arrays of strings - how to? Pin
Johan Hakkesteegt23-Nov-06 23:20
Johan Hakkesteegt23-Nov-06 23:20 
GeneralRe: Marshal arrays of strings - how to? Pin
marccp26-Nov-06 23:09
marccp26-Nov-06 23:09 
GeneralRe: Marshal arrays of strings - how to? Pin
Johan Hakkesteegt27-Nov-06 0:02
Johan Hakkesteegt27-Nov-06 0:02 
GeneralRe: Marshal arrays of strings - how to? Pin
marccp27-Nov-06 1:27
marccp27-Nov-06 1:27 
GeneralRe: Marshal arrays of strings - how to? Pin
marccp27-Nov-06 3:13
marccp27-Nov-06 3:13 
QuestionWhat is the meaning of below statement. Pin
ashwath197922-Nov-06 2:19
ashwath197922-Nov-06 2:19 
AnswerRe: What is the meaning of below statement. Pin
Dave Sexton22-Nov-06 2:30
Dave Sexton22-Nov-06 2:30 
AnswerRe: What is the meaning of below statement. Pin
Christian Graus22-Nov-06 7:36
protectorChristian Graus22-Nov-06 7:36 
GeneralRe: What is the meaning of below statement. Pin
Dave Sexton22-Nov-06 20:10
Dave Sexton22-Nov-06 20:10 
QuestionData table questions Pin
cstrader23222-Nov-06 1:34
cstrader23222-Nov-06 1:34 
AnswerRe: Data table questions Pin
Johan Hakkesteegt24-Nov-06 1:14
Johan Hakkesteegt24-Nov-06 1:14 
QuestionMirror Image Pin
danasegaranea21-Nov-06 23:55
danasegaranea21-Nov-06 23:55 
AnswerRe: Mirror Image Pin
Kapil Thakur22-Nov-06 0:28
Kapil Thakur22-Nov-06 0:28 
AnswerRe: Mirror Image Pin
Christian Graus22-Nov-06 7:36
protectorChristian Graus22-Nov-06 7:36 
QuestionMulti-dimensionnal array, but with differenty type in the columns Pin
ChPortos21-Nov-06 23:55
ChPortos21-Nov-06 23:55 
AnswerRe: Multi-dimensionnal array, but with differenty type in the columns Pin
Kevin McFarlane22-Nov-06 1:20
Kevin McFarlane22-Nov-06 1:20 
GeneralRe: Multi-dimensionnal array, but with differenty type in the columns Pin
ChPortos22-Nov-06 2:19
ChPortos22-Nov-06 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.