VB6 DLL Strings

mtarifi

New member
Joined
Apr 2, 2006
Messages
4
Programming Experience
1-3
hi:
i am using dll that was written for vb6 environment , does it work in vb.net?
i tried to but still there is a problem in Strings is there a difference between vb6 String and VB.net?
 

mtarifi

New member
Joined
Apr 2, 2006
Messages
4
Programming Experience
1-3
i will describe for you my problem in more details:
Public Function RescivedCommand(ByVal number As Integer, byval data As string) As Boolean

this function is part o vb6 dll , when i execute this function the length of data is 160 in vb6.
but when i tried to use it in vb.net data is only one character instead of 160.
and when i read the documentation of the dll i found that data is fixed length.
is the problem that no more fixed length strings in vb.net, if so is there any solution to this problem

 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,346
Location
Sydney, Australia
Programming Experience
10+
You can use the VBFixedString attribute in VB.NET to simulate a fixed-length VB6 string:
VB.NET:
<VBFixedString(160)> Dim myString As String
When you pass the myString variable to your VB6 method it will be perceived as a fixed-length string, even though in VB.NET it is not actually of fixed-length.
 

mtarifi

New member
Joined
Apr 2, 2006
Messages
4
Programming Experience
1-3
no Actually this solution didnot help me. i tried someting different which is
<MarshalAs(UnmanagedType.TBStr)>
<MarshalAs(UnmanagedType.BStr)>
and this solve my problrm to use the unmanaged types used previously in vb6 in vb.net environment

 
Top Bottom