Imports System.Runtime.InteropServices Imports Microsoft.VisualBasic PublicClass Form1Class Form1 <DllImport("TestMemorySpace.dll", EntryPoint:="SetValueByte", SetLastError:=True, _ CharSet:=CharSet.Unicode, ExactSpelling:=True, _ CallingConvention:=CallingConvention.StdCall)> _ PublicSharedSub SetValueByte()Sub SetValueByte(ByVal bytes() AsByte) _ ' Leave the body of the function empty. End Sub <DllImport("TestMemorySpace.dll", EntryPoint:="GetValueByte", SetLastError:=True, _ CharSet:=CharSet.Unicode, ExactSpelling:=True, _ CallingConvention:=CallingConvention.StdCall)> _ PublicSharedSub GetValueByte()Sub GetValueByte(ByVal bytes() AsByte) _ ' Leave the body of the function empty. End Sub <DllImport("TestMemorySpace.dll", EntryPoint:="SetValueString", SetLastError:=True, _ CharSet:=CharSet.Unicode, ExactSpelling:=True, _ CallingConvention:=CallingConvention.StdCall)> _ PublicSharedSub SetValueString()Sub SetValueString(ByVal a() AsByte) _ ' Leave the body of the function empty. End Sub <DllImport("TestMemorySpace.dll", EntryPoint:="GetValueString", SetLastError:=True, _ CharSet:=CharSet.Unicode, ExactSpelling:=True, _ CallingConvention:=CallingConvention.StdCall)> _ PublicSharedSub GetValueString()Sub GetValueString(ByVal a() AsByte) _ ' Leave the body of the function empty. End Sub PrivateSub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load End Sub PrivateSub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim bytes() AsByte bytes = System.Text.Encoding.Default.GetBytes(TextBox1.Text.ToString) SetValueString(bytes) End Sub PrivateSub Button2_Click()Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim bytes(4096) AsByte GetValueString(bytes) TextBox1.Text = System.Text.Encoding.Default.GetString(bytes) End Sub End Class