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
Debug.WriteLine(a)

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

.3333333

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
        Debug.WriteLine(a)
    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!

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
Debug.WriteLine(a)


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

i use PAUSE/F8 to step into the code
capture
it is working just fine ! what's the problem ?

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!

"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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.