I'm using Mastering Visual Basic 2010 <book and it tells me...

In a button's Click event handler, declare two variables as follows:

Dim a As Single, b As Double

Then enter the following statements:

a = 1 / 3

Run the application, and you should get the following result in the Output window:


So I did:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Integer, b As Double
        a = 1 / 3
    End Sub
End Class

I then debug and click the button and nothing even comes up... am I missing something or did he miss do something? I just don't understand and I mentally can't move on until I figure this out... Thanks!

Edited by cege: n/a

6 Years
Discussion Span
Last Post by ÜnLoCo

you have to show the "output" window.
if no output is shown there then check the "immediate window"
there's an option in Tools> Options> Debugging> General options> "Redirect all Output Window text to the Immediate Window"
uncheck it if you want.


That worked and then I had to add:

Dim a As Integer, b As Double
a = 1 / 3
Debug.WriteLine(a) <Break was inserted here
a = a * 100000

Break the application by pressing Ctrl+Brk but I'm on a laptop and simply right click and insert one that way and then appendd the following lines to the end of the previous code segment which is waht i added

and then it showed the .3333333 thing

but was supposed to change to 33333.34 and its not doing correctly anymore

Edited by cege: n/a


try it with "b As Double" included, because that is what was there but maybe he forgot to mention in the book to remove it... I will try it like you did and see if it works.

*Edit: Yep, that's what it was. It worked for me, and the F8 ran through some stuff not sure what it was, but it worked I guess lol thanks man!

Edited by cege: n/a


"b" has nothing to do with it !
it is an unused variable sitting there for future use in the book maybe.
and "a" should be single not integer !!
integers will give you zeros because they don't hold float numbers, they round them ;)
and round(0.3333) is 0

Edited by ÜnLoCo: n/a

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.