Solved

How to replace LENB Function in VB .net

Posted on 2004-08-24
8
4,522 Views
Last Modified: 2009-09-22
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


0
Comment
Question by:TOPIO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11886273
Dim Len As Int32
Len = MyString.Length()

-Baan
0
 
LVL 3

Expert Comment

by:imu79
ID: 11886457
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.Marshal.SizeOf(bInData)
ReDim arrData(bLen - 1)


hope this helps..
Imran.
0
 
LVL 10

Author Comment

by:TOPIO
ID: 11886542
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_Client.NET\CSocket.vb(200):
'InteropServices' is not a member of 'System'.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11886547
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
0
 
LVL 10

Author Comment

by:TOPIO
ID: 11886552
I also tried
ReDim arrData(System.InteropServices.Marshal.SizeOf(bytData) - 1)
and I get the same error
0
 
LVL 3

Accepted Solution

by:
imu79 earned 500 total points
ID: 11886593
ooops sorry..its  System.Runtime.InteropServices.Marshal.SizeOf( )

or just include this line:

Imports System.Runtime.InteropServices

at the top of your code..

hope this helps..
Imran.
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11886661
wait.. I got it...  LenB  is Len() in vb.net

-Baan
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11886669
ohhh... I am late..  n e way... this link will be useful to you... :))
http://www.netcoole.com/asp2aspx/vbhtml/vbfuncs.htm

-Baan
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net WebRequest Code from JSON curl 7 86
"Emulate" TAB key when press Enter Key 3 67
Convert Ctime to date time in textfile? 7 61
Web page design problem 3 12
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question