Example code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show(Val(TextBox1.Text), "Val of text input")
End Sub
End Class
Anyhow out of simple curiosity I am wondering why it does this?
From some other posts & personal experience I know VAL(expression) isn’t recommended & is just a legacy function from VB6 days. I tried every other alphabet letter & none caused this issue, I also tried a couple variations & it appears any number after d or e add that many zeros (seems like its multiplying). I understand that the value may be overflowing the data-type VAL placed it in. I see e is the default variable for the sub-procedure, so that’s probably why, but I can’t figure out any logic to d.
Please make it noted I am very new to VB.NET, just got down with a college course & haven’t built any actual apps. Furthermore our teacher seemingly didn’t teach us error-handling which I am very interested in, as my current work situation has some rather old apps that have issues. Would also like any recommended error-handling articles/readings
The Val() function “returns the numbers contained in a string as a numeric value of appropriate type” (cit. from http://msdn.microsoft.com/en-us/library/k7beh1x9(v=vs.71).aspx).
If you set a string value like 5exxx it means 5 * 10^xxx; but pay attention: the function returns a double and double goes approximately from ±5.0 x 10^-324 to ±1.7 x 10^308; so, for example, the string 5e307 works but 5e308 doesn’t, returning overflow.
If you use some other letters “function stops reading the string at the first character it cannot recognize as part of a number”, so it doesn’t return overflow.
I hope it was helpful. Have a nice new year!