I had to take a VB.NET test today
I had to take a VB.NET test today for an employer. This question was included.
If you run the code below what will the value of label1.Text
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Double
Dim s As String
Try
s = "i = "
i = 1 / 0
s = s & "infinity"
Catch
s = s & "undefined"
Finally
label1.Text = s
End Try
End Sub
My answer was "i = infinity" but was told I was wrong. Can someone explain how I am wrong? They told me the correct answer is "i = undefined". I think they caught themselves in their own trick question.
Re: I had to take a VB.NET test today
Quote:
Originally posted by VBGuy
I had to take a VB.NET test today for an employer. This question was included.
If you run the code below what will the value of label1.Text
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Double
Dim s As String
Try
s = "i = "
i = 1 / 0
s = s & "infinity"
Catch
s = s & "undefined"
Finally
label1.Text = s
End Try
End Sub
My answer was "i = infinity" but was told I was wrong. Can someone explain how I am wrong? They told me the correct answer is "i = undefined". I think they caught themselves in their own trick question.
I just ran your code, and I get "i = infinity". Their completely wrong!!!!
The double data type allows for NaN's and infinities.
Re: Re: I had to take a VB.NET test today
Quote:
Originally posted by Hu Flung Dung
I just ran your code, and I get "i = infinity". Their completely wrong!!!!
The double data type allows for NaN's and infinities.
that's what I said :(