473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Could this be a bug in VB.NET ??

In VS.NET 2003 (VB.NET):
Microsoft Development Environment 2003 Version 7.1.3088
Microsoft .NET Framework 1.1 Version 1.1.4322 SP1

Here's a small piece of code which works fine:

Private Sub Button3_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button3.Click
' Convert a Decimal to an Int32 Array
' and then back to a Decimal
Dim dec1 As Decimal
Dim dec2 As Decimal
dec1 = Decimal.Parse(TextBox1.Text)
Dim i32A As Int32()
Dim i32B(4) As Int32
i32A = Decimal.GetBits(dec1)
Debug.Write(i32A(0).ToString & vbCrLf)
Debug.Write(i32A(1).ToString & vbCrLf)
Debug.Write(i32A(2).ToString & vbCrLf)
Debug.Write(i32A(3).ToString & vbCrLf)
i32B = i32A
Debug.Write(i32B(0).ToString & vbCrLf)
Debug.Write(i32B(1).ToString & vbCrLf)
Debug.Write(i32B(2).ToString & vbCrLf)
Debug.Write(i32B(3).ToString & vbCrLf)
dec2 = New Decimal(i32B)
TextBox3.Text = dec2.ToString()
End Sub
-----
Input: 43683683.368268265
-----
Debug: 497381865
10170900
0
589824
497381865
10170900
0
589824
-----
Output: 43683683.368268265
-----

And here's a similar piece which bombs and I can't figure
out why:

Private Sub Button3_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button3.Click
' Convert a Decimal to an Int32 Array
' then to an array of (unsigned) bytes
' then back to an Int32 Array
' and then back to a Decimal
Dim dec1 As Decimal
Dim dec2 As Decimal
dec1 = Decimal.Parse(TextBox1.Text)
Dim i32A As Int32()
Dim i32B(4) As Int32
i32A = Decimal.GetBits(dec1)
Debug.Write(i32A(0).ToString & vbCrLf)
Debug.Write(i32A(1).ToString & vbCrLf)
Debug.Write(i32A(2).ToString & vbCrLf)
Debug.Write(i32A(3).ToString & vbCrLf)
Dim BA As Byte()
Dim BB As Byte()
Dim BC As Byte()
Dim BD As Byte()
BA = BitConverter.GetBytes(i32A(0))
BB = BitConverter.GetBytes(i32A(1))
BC = BitConverter.GetBytes(i32A(2))
BD = BitConverter.GetBytes(i32A(3))
i32B(0) = BitConverter.ToInt32(BA, 0)
i32B(1) = BitConverter.ToInt32(BB, 0)
i32B(2) = BitConverter.ToInt32(BC, 0)
i32B(3) = BitConverter.ToInt32(BD, 0)
Debug.Write(i32B(0).ToString & vbCrLf)
Debug.Write(i32B(1).ToString & vbCrLf)
Debug.Write(i32B(2).ToString & vbCrLf)
Debug.Write(i32B(3).ToString & vbCrLf)
dec2 = New Decimal(i32B) <-- Error is Here **
TextBox3.Text = dec2.ToString()
End Sub
-----
Input: 43683683.368268265
-----
Debug: 497381865
10170900
0
589824
497381865
10170900
0
589824
-----
Output: An unhandled exception of type
'System.ArgumentException' occurred
in mscorlib.dll

Additional information: Decimal byte
array constructor requires an array
of length four containing valid
decimal bytes.
-----

But note that the Debug lines still show the Int32
arrays are identical. Any ideas?

Jul 29 '05 #1
0 1102

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

Similar topics

1
53411
by: Matthias Ludwig | last post by:
I'm trying to create a directory on the web server with a vb.net code: .... Dim dirName As String = "w:\filepath\images" If Not Directory.Exists(dirName) Then...
1
6913
by: Afaq | last post by:
Hi, After adding large number of empty resource files (which will be updated later), we are not able to compile the project. the following is the output of the build process. It fails while...
20
5274
by: ctyrrell | last post by:
Does anyone have any idea how to recover from a run-time error 3002 which I get after creating a workspace 242 times? Or better yet, avoid getting it in the first place? I am creating a...
2
6915
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it,...
2
12691
by: ruben20 | last post by:
Hi: I've migrated a couple of weeks ago from 7.4.2 to 7.4.5 and I am getting this error after executing a query: Warning: pg_exec() query failed: ERROR: could not access status of transaction...
0
11251
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
0
7785
by: jhansen | last post by:
I am getting informational warnings about the following app.config and indicate the following. I am using C# visual studio 2005 and used the Settings.settings to set up my values scoped as...
22
3035
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
1
9284
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
1
8246
by: vineetbindal | last post by:
Hi All, I am new to silverlight and i am following a tutorial. In order to connect to database in silverlight application i need to add a referance to a service. which gives me an error that the...
0
7093
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
7287
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
7349
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
7467
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
5594
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
5022
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
1521
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 ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.