TOPIO
asked on
How to replace LENB Function in VB .net
I have an VB6 program tha uses the function LENB
According to the Error Code I get from the VB.net enviroment
"The AscB, ChrB, InstrB, LeftB, LenB, MidB, and RightB functions in Visual Basic 6.0 were string-handling functions that returned their results in bytes. They were used primarily for converting strings for use by double-byte character set languages.
In Visual Basic .NET, encoding and decoding functions in the System.Text namespace replace this functionality. For more information, see Globalizing and Localizing Applications."
If I go to Globalizing and localizing applications
I have read a lot of information and have not found out how to solve this particular Issue
The code in question is
ReDim arrData(LenB(blnData) - 1)
I'm very new at Vb.net and my training did not include a lot of information in upgrading VB6 Apps
According to the Error Code I get from the VB.net enviroment
"The AscB, ChrB, InstrB, LeftB, LenB, MidB, and RightB functions in Visual Basic 6.0 were string-handling functions that returned their results in bytes. They were used primarily for converting strings for use by double-byte character set languages.
In Visual Basic .NET, encoding and decoding functions in the System.Text namespace replace this functionality. For more information, see Globalizing and Localizing Applications."
If I go to Globalizing and localizing applications
I have read a lot of information and have not found out how to solve this particular Issue
The code in question is
ReDim arrData(LenB(blnData) - 1)
I'm very new at Vb.net and my training did not include a lot of information in upgrading VB6 Apps
Length gives you the number of characters just like the Len( ) function and not the bytes.
You might want to try this:
Dim bLen as Integer
'per documentation, Marshal.SizeOf( ) returns the unmanaged size of an object in bytes.
bLen = System.InteropServices.Mar shal.SizeO f(bInData)
ReDim arrData(bLen - 1)
hope this helps..
Imran.
You might want to try this:
Dim bLen as Integer
'per documentation, Marshal.SizeOf( ) returns the unmanaged size of an object in bytes.
bLen = System.InteropServices.Mar
ReDim arrData(bLen - 1)
hope this helps..
Imran.
ASKER
Dotnetlover: as Imu mentioned Length gives you the number of characters
as far as your code imu79 I get the error
C:\My Documents\Visual Studio Projects\csocket\FTP_Clien t.NET\CSoc ket.vb(200 ):
'InteropServices' is not a member of 'System'.
as far as your code imu79 I get the error
C:\My Documents\Visual Studio Projects\csocket\FTP_Clien
'InteropServices' is not a member of 'System'.
Sorry about my post... I didn't read the question properly. you want the byte length.... mine will give you number of characters. you can ignore my post..
-Baan
-Baan
ASKER
I also tried
ReDim arrData(System.InteropServ ices.Marsh al.SizeOf( bytData) - 1)
and I get the same error
ReDim arrData(System.InteropServ
and I get the same error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
wait.. I got it... LenB is Len() in vb.net
-Baan
-Baan
ohhh... I am late.. n e way... this link will be useful to you... :))
http://www.netcoole.com/asp2aspx/vbhtml/vbfuncs.htm
-Baan
http://www.netcoole.com/asp2aspx/vbhtml/vbfuncs.htm
-Baan
Len = MyString.Length()
-Baan