How to convert LSet in VB6 to VB.Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

We have a VB6 windows application. It had LSet to assign a User_Defined Type, a string, into another User_Defined Type, an Array of String. It looked like

Type tPTStrin
PTString As String * 2
End Typ

Type tPTArra
PTArray (11) As String *
End Typ

Dim PTS as tPTStrin
Dim PTA As tPTArra

PTS.PTString = "ABCDEFGHIJKLMNOPQRSTU" '--22 character

LSet PTA = PT

We got PTA.PTArray(0) = "AB", PTA.PTArray(2) ="CD",...... PTA.PTArray(11) = "TU"

What correspodent Function of LSet of VB6 we can use in VB.Net (or sample code)

Thanks
 
Unfortunately Ken's link just says you can't do it in .net without really
giving you any help on where to go next

basically this is not a "typesafe" operation - you are taking a block of
memory and trying to treat it in different ways. .net does not allow you to
just play fast and loose with pieces of memory like this.

you will need to rewrite the code to represent the data in another way. for
instance you could have an arraylist of 2 character strings and then write a
method to produce the long version on demand, or you could have a single
StringBuffer and write a method to return or replace any two-character pair.

I suspect if you look at the requirement you will find out that the original
way of doing it was not a great solution and you will be able to find a much
better one using .net.

if the reason it was written like this was to give very fast performance,
you might need to experiment with several ways to do it.

Andy
 
Hi,

Add Imports Microsoft.VisualBasic to the top of your file so vb.net knows
where to find lset.

Ken
 
Back
Top