473,474 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C# to VB transformation

Hi,

Checking out some byte shifting code in C#, and interested in putting it
into VB.NET. Anyone know how to transform the following into VB?

public static void Put32Bit(long value, byte[]b, int offset)
{
b[0+offset] = (byte) ((value & 0xff000000) >> 24);
b[1+offset] = (byte) ((value & 0x00ff0000) >> 16);
b[2+offset] = (byte) ((value & 0x0000ff00) >> 8);
b[3+offset] = (byte) (value & 0x000000ff);
}

Thanks for any help.
Nov 21 '05 #1
3 4494
On 2005-04-26, OpticTygre <op********@adelphia.net> wrote:
Hi,

Checking out some byte shifting code in C#, and interested in putting it
into VB.NET. Anyone know how to transform the following into VB?

public static void Put32Bit(long value, byte[]b, int offset)
{
b[0+offset] = (byte) ((value & 0xff000000) >> 24);
b[1+offset] = (byte) ((value & 0x00ff0000) >> 16);
b[2+offset] = (byte) ((value & 0x0000ff00) >> 8);
b[3+offset] = (byte) (value & 0x000000ff);
}

Thanks for any help.

Hmmm... (untested :)

Public Shared Sub Put32Bit _
(value As Long, b() As Byte, offset As Integer)

b(0 + offset) = CType (((value & &HFF000000) >> 24), Byte)
b(1 + offset) = CType (((value & &H00FF0000) >> 16), Byte)
b(2 + offset) = CType (((value & &H0000FF00) >> 8), Byte)
b(3 + offset) = CType (((value & &H000000FF)), Byte)

End Sub

--
Tom Shelton [MVP]
Nov 21 '05 #2
From our Instant VB C# to VB.NET converter:

Public Shared Sub Put32Bit(ByVal value As Long, ByVal b As Byte(), ByVal
offset As Integer)
b(0+offset) = CByte((value And &Hff000000) >> 24)
b(1+offset) = CByte((value And &H00ff0000) >> 16)
b(2+offset) = CByte((value And &H0000ff00) >> 8)
b(3+offset) = CByte(value And &H000000ff)
End Sub

Hope this helps,
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"OpticTygre" wrote:
Hi,

Checking out some byte shifting code in C#, and interested in putting it
into VB.NET. Anyone know how to transform the following into VB?

public static void Put32Bit(long value, byte[]b, int offset)
{
b[0+offset] = (byte) ((value & 0xff000000) >> 24);
b[1+offset] = (byte) ((value & 0x00ff0000) >> 16);
b[2+offset] = (byte) ((value & 0x0000ff00) >> 8);
b[3+offset] = (byte) (value & 0x000000ff);
}

Thanks for any help.

Nov 21 '05 #3
On 2005-04-26, David Anton <Da********@discussions.microsoft.com> wrote:
From our Instant VB C# to VB.NET converter:

Public Shared Sub Put32Bit(ByVal value As Long, ByVal b As Byte(), ByVal
offset As Integer)
b(0+offset) = CByte((value And &Hff000000) >> 24)
b(1+offset) = CByte((value And &H00ff0000) >> 16)
b(2+offset) = CByte((value And &H0000ff00) >> 8)
b(3+offset) = CByte(value And &H000000ff)
End Sub


Nuts! I for got to change the & to And...
--
Tom Shelton [MVP]
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
3
by: pradeep gummi | last post by:
I have an XML FILE that is to be converted to Plain Text using an XSL file. Since I just want plain text, I do not want to set any root element during transformation.And if I do not any root...
4
by: Kevin Dean | last post by:
I'm trying to create an XSL transformation that will strip out development-specific attributes from deployment descriptors and other XML files. I have already successfully done so with web.xml but...
7
by: CK | last post by:
Hello, I have the 60 MB XML string and I am coding a program in Visual Basic to run a XSL transformation on it. Currently, I'm using the Microsoft standard MSXML 2.0 to create a DOM document, load...
8
by: Will | last post by:
I was thrust into XML about 2 weeks ago and don't know much yet. From another department in the corp I am receiving an XML file which concatenates nodes all on one line i.e....
4
by: Mike Conmackie | last post by:
Hi Folks, I've probably omitted something very basic but I have no idea what it might be. The results of my transformation _should_ be an xml file but all I get is the xml declaration...
6
by: Jain, Pranay Kumar | last post by:
Hi All, We have created a simple application that takes a dataset and generates the data in Excel schema format. It uses an xslt file to do the transformation for excel 2002 and so on. We are...
2
by: TomekR | last post by:
Hello ! I was developing xslt sheet lately and - experimenting - I made mistake resulting in that, the effect of the transformation is not well-formed xml document. I made these tests using...
2
by: HendrikLeder | last post by:
Hello everybody :-) Next year I`ll write my diploma in computer science for business (It`s a degree in Germany) and I`ve some questions about the topic. The diploma will handle about refactoring...
1
by: newbie | last post by:
This is probably a too general question, thanks for any feedback in advance. I am trying to write a class to do transformation on a data set. I want to make it easy to maintain in the long-run...
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
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...
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
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,...
1
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.