473,811 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem porting C# code 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 1273
Rabbit
12,516 Recognized Expert Moderator MVP
Try vbLf or vbCrLf. Or you could compare the ASCII codes. 10 is LF and 13 is CR.
Jan 18 '11 #2

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

Similar topics

5
1641
by: Kenton Groombridge | last post by:
Hi, I previous posted this in a gcc and g++ groups since that is the compiler I am working with, but I didn't get any response. Hopefully these are the right groups for this question. I am working (actually playing) on porting Alien vs Predator to Linux. I am using the code that is available via CVS from icculus.org. I recently upgraded my gcc to 3.4.1 and now a portion of the code doesn't compile. Nothing in the code has changed.
11
2949
by: Errol Neal | last post by:
Hi all, Not sure if this is a question for a php list or this one, but I'll give it a shot and if I am wrong, please do not crucify me. :-) There is a php based sourceforge project called mailwatch. (http://www.sourceforge.net/projects/mailwatch) It logs data from the excellent Mailscanner security product into a mysql database. Now, I am not a php programmer,
2
1224
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 "class TestT<bool> __cdecl operator+(class TestT<bool> const &,class TestT<bool> const &)" (??H@YA?AV?$TestT@_N@@ABV0@0@Z) referenced in function "void __cdecl f(void)" (?f@@YAXXZ)
3
2750
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 declaration of a static fuction. I have a static function called GetDocID() that returns a CString.
3
3077
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 :
3
1811
by: Martin | last post by:
Hi all, I have some VBScript code that I am trying to port over to VB.NET. I am receiving an error "Cast from type 'Field' to type 'String' is not valid." when calling the MapLegacyExchangeDN method. I'm thinking that the parameter sDirName isn't being properly passed to the function. The same code works in VBScript. Can someone help, this should be an easy one but I cant figure it out! And yes, I am a VB.NET newbie! Thanks.
4
1880
by: Ted | last post by:
Understand, I have developed a number of applications using RDBMS, including MySQL, PostgreSQL and MS Access, but this is my first experience with MS SQL. I'd bet my bottom dollar that MS SQL supports what I need, but I just haven't found where it is explained in any detail in the documentation I have. The pages I have found strike me as a little too terse for my needs. In MySQL, I used statements like: PRIMARY KEY (`ic_contact_id`),...
4
1988
by: Ian | last post by:
I would like to hear from others who have considered and/or ported code from traditional C++ to C++/CLI. The class library I am considering porting to C++/CLI was written in traditional C++ with STL and a touch of MFC. It represents the back end to my applications and, among a number of other things, it performs all file I/O and data management operations (i.e. no GUI). Why would I consider porting it to C++/CLI when it works just...
3
1928
by: ppanta | last post by:
Hi, I'm trying to read data that generated in a big-endian system (SPARC) in the little-endian cpu (intel). The following is the code I used. Please note that the following codes are fully working in SUN but not in the LINUX system I'm currently using. =========================================== void Initialize(.... char *FreezeTableDSN) { int j, handle;
6
1825
by: ladycyradis | last post by:
I have a bit of a problem with some code in an Access 2003 database that I’m hoping someone can help me with. (If my code seems a little disjointed, it's because it is mostly copied from other answers posted here, and adjusted to suit my needs as required, but I think I've either left something out or used something I shouldn't have.) Background I have a pop-up form that has a number of combo boxes and a multi-select list box. Users can...
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10379
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.