473,395 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Code worked fine in VB6 but not .NET

The code worked perfectly fine in VB6 for converting a decimal length to
binary hex, but in .NET it only works when the iNum variable doesn't
contain a zero. If zero is passed in then I lose everything in the
string. Does anyone
know how to make the Chr(0) Function work exactly as it did in VB 6. If
you pass 342,2 as the arguments then everything works fine, but if you
pass 54,2 then it returns blank. Your help would be greatly
appreciated!!!!

Public Function SetBinaryLengthofMsg(ByRef lLen As Integer, ByRef
lPosLen As Integer) As String

lLen = decimal length value to be converted to binary
lPosLen = number of bytes in which to store binary length value (max
bytes = 3)

Dim iNum As Integer
Dim iRemainder As Short
Dim iLoop As Short
Dim lTmpLenVal As Integer
Dim szTmpLenString As String
Dim sb As New StringBuilder
'---set temporary decreasing value to length value
lTmpLenVal = lLen
szTmpLenString = ""

'---loop backwards breaking out length value into bytes
For iLoop = lPosLen To 1 Step -1

Select Case iLoop
Case 3
iNum = Int(lTmpLenVal / 65536)
sb.Append(Chr(iNum))
lTmpLenVal = lTmpLenVal Mod 65536
Case 2
iNum = Int(lTmpLenVal / 256)
sb.Append(Microsoft.VisualBasic.Chr(iNum))
lTmpLenVal = lTmpLenVal Mod 256
Case 1
iNum = lTmpLenVal
sb.Append(Microsoft.VisualBasic.Chr(iNum))
End Select

Next iLoop

'---return length value in binary hex
SetBinaryLengthofMsg = sb.ToString()
End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
1 1197
Is his message posted here by mistake ? VB stuff in the C# discussion ...

"Chad Dalton" <cd*****@jackhenry.com> wrote in message
news:er****************@TK2MSFTNGP12.phx.gbl...
The code worked perfectly fine in VB6 for converting a decimal length to
binary hex, but in .NET it only works when the iNum variable doesn't
contain a zero. If zero is passed in then I lose everything in the
string. Does anyone
know how to make the Chr(0) Function work exactly as it did in VB 6. If
you pass 342,2 as the arguments then everything works fine, but if you
pass 54,2 then it returns blank. Your help would be greatly
appreciated!!!!

Public Function SetBinaryLengthofMsg(ByRef lLen As Integer, ByRef
lPosLen As Integer) As String

lLen = decimal length value to be converted to binary
lPosLen = number of bytes in which to store binary length value (max
bytes = 3)

Dim iNum As Integer
Dim iRemainder As Short
Dim iLoop As Short
Dim lTmpLenVal As Integer
Dim szTmpLenString As String
Dim sb As New StringBuilder
'---set temporary decreasing value to length value
lTmpLenVal = lLen
szTmpLenString = ""

'---loop backwards breaking out length value into bytes
For iLoop = lPosLen To 1 Step -1

Select Case iLoop
Case 3
iNum = Int(lTmpLenVal / 65536)
sb.Append(Chr(iNum))
lTmpLenVal = lTmpLenVal Mod 65536
Case 2
iNum = Int(lTmpLenVal / 256)
sb.Append(Microsoft.VisualBasic.Chr(iNum))
lTmpLenVal = lTmpLenVal Mod 256
Case 1
iNum = lTmpLenVal
sb.Append(Microsoft.VisualBasic.Chr(iNum))
End Select

Next iLoop

'---return length value in binary hex
SetBinaryLengthofMsg = sb.ToString()
End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2

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

Similar topics

10
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
7
by: Alan Silver | last post by:
Hello, I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am having problems....
8
by: Robert Dufour | last post by:
Dim message As New MailMessage("mymail@mydomain.com", "mymail@mydomain.com", "Test", "Test") Dim emailClient As New SmtpClient("localhost") emailClient.Send(message) The IIS server is...
3
by: Iluvatar | last post by:
Hi, last week our project upgraded from vs.net 2005 to vs.net 2008. Our project still uses framework 2.0, because the deployment servers are not 3.x ready yet. Everything so far while migrating...
8
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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...

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.