473,466 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem porting C# to VB

Paul Johnson
97 New Member
Hi,

I have a bit of code which is causing me a few problems to port from C# to VB.NET

The C# looks like this

Expand|Select|Wrap|Line Numbers
  1.             byte[] serverbuff = new Byte[1024];
  2.             int count = 0;
  3.             while (true)
  4.             {
  5.                 byte[] buff = new Byte[2];
  6.                 int bytes = stream.Read(buff, 0, 1 );
  7.                 if (bytes == 1)
  8.                 {
  9.                     serverbuff[count] = buff[0];
  10.                     count++;
  11.  
  12.                     if (buff[0] == '\n')
  13.                     {
  14.                         break;
  15.                     }
  16.                 }
  17.                 else
  18.                 {
  19.                        break;
  20.                 };
  21.             };
  22.  
I've ported it, but the final if is causing a problem as I can't use ControlChars.Lf - the new code looks like this

Expand|Select|Wrap|Line Numbers
  1.             Dim serverbuff As Byte() = New [Byte](1023) {}
  2.             Dim count As Integer = 0
  3.             While (True)
  4.                 Dim buff As Byte() = New [Byte](1) {}
  5.                 Dim bytes As Integer = stream.Read(buff, 0, 1)
  6.                 If (bytes = 1) Then
  7.                     serverbuff(count) = buff(0)
  8.                     count += 1
  9. 'The line below fails
  10.                     If (buff(0) = ControlChars.Lf) Then
  11.                         Exit While
  12.                     End If
  13.                 Else
  14.                     Exit While
  15.                 End If
  16.  
  17.             End While
  18.  
Any idea on how to go about fixing this? It's the only part that fails

Paul
Jan 18 '11 #1
1 1068
horace1
1,510 Recognized Expert Top Contributor
you are attempting to compare a Byte with a Char, try converting the Byte to a Char, e.g.
Expand|Select|Wrap|Line Numbers
  1.        If (Chr(buff(0)) = ControlChars.Lf) Then
  2.  
Jan 23 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ryan Liu | last post by:
Hi All, Now I am porting CC to GCC and I have some problems. Would you mind tell me some document which have some description how to port CC to GCC ?? Thank you very much. Ryan
4
by: Chris Travers | last post by:
Hi all; A few years ago, I set about porting a PHP application from MySQL to PostgreSQL, after realizing that MySQL wasn't going to be able to handle it. In order to do this, I built a light,...
19
by: navin_2016 | last post by:
Hi, Can somone please describe the problems one would face when we try to port a software written in C to another platform some of them being endianness ,alignment,data types etc ? It would be...
2
by: Jay | last post by:
Hi, Can anyone tell me why the following code doesn't work on 7.1? It's been ok with previous versions. The error given by the linker is: rtwnd.obj : error LNK2019: unresolved external symbol...
3
by: Rob C | last post by:
I am rebuilding a VC++ w/ MFC Project from Visual Studio V6 in Visual Studio .NET 2003. There are 2 errors that I am getting that I do not get when I build using V6. 1) problem with my...
3
by: slarti | last post by:
My VS6 version used #include <fstream.h> which for VS.net I had to change to #include <fstream> using namespace std; Now I get a compiler error :
1
by: Bill | last post by:
Does anyone know how to fix this problem? On form submittal I'm getting the following error in Visual Studio 2005: The state information is invalid for this page and might be corrupted....
8
by: nurxb01 | last post by:
Hi I have a very basic doubt. The application i'm working on has some old code already in place. There are some struct data type decleared in a .h file and are being used for RPC communication....
1
Paul Johnson
by: Paul Johnson | last post by:
Hi, I have a bit of code which is causing me a few problems to port from C# to VB.NET The C# looks like this byte serverbuff = new Byte; int count = 0; while (true)
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.