Wrox Programmer Forums
|
BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7
This is the forum to discuss the Wrox book Beginning Microsoft Visual Basic 2008 by Thearon Willis, Bryan Newsome; ISBN: 9780470191347
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2009, 05:17 PM
Registered User
 
Join Date: Mar 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Smile NEED EXPLANATION WHY CODE GIVES ERRORS

I AM KEYING IN THE CODE FOR BEGINNING VISUAL BASIC DIRECTLY FROM THE AUTHORS EXAMPLE. I HAVE DONE IT SEVERAL TIMES I KEEP GETTING THE SAME ERRORS. IS THE CODE WRONG FROM THE AUTHORS.? SEE THE CODE BELOW.
CODE
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'DECLARE VARIABLE
Dim DBLAREA As Double

'CALCULATE THE AREA FOR A CIRCLE WITH A RADIUS OF 100
DBLAREA = CalculateAreaFromRadius(100)

'DISPLAY THE RESULTS
MessageBox.Show(DBLAREA.ToString, "AREA OF 100")
'CALCULATEAREAFROM RADIUS - FIND THE AREA OF A CIRCLE
'CALCULATEAREAFROM RADIUS - FIND THE AREA OF A CIRCLE


End Sub
Private Sub SayHello()
'display a message box
MessageBox.Show("I Have Changed it!", "three buttons")


End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'call your method
SayHello()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'call your method
SayHello()

End Sub
End Class

'CalculateAreaFromRadius -find the area of a circle
Private Function CalculateAreaFromRadius(ByVal radius As Double) As Double
'declare variables
Dim dblRadiusSquared As Double
Dim dblResult As Double

'square the radius
dblRadiusSquared = radius * radius

'multiply it by pi
dblResult = dblRadiusSquared * Math.PI
'return the result
Return dblResult
End Function
/CODE
Error 1 Name 'CalculateAreaFromRadius' is not declared.
Error 2 Statement is not valid in a namespace.

I DON'T UNDERSTAND WHAT THE PROBLEM IS.
HELP
 
Old March 23rd, 2009, 07:54 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You have your
Code:
End Class
*BEFORE* your function!

END CLASS should be the very very very last thing in the file.
 
Old March 24th, 2009, 10:06 AM
Registered User
 
Join Date: Mar 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Old Pedant reply

Quote:
Originally Posted by Old Pedant View Post
You have your
Code:
End Class
*BEFORE* your function!

END CLASS should be the very very very last thing in the file.
DEAR Old Pedant: I KNOW THIS IS A VERY BASIC ERROR, BUT I AM JUST STARTING AND THE BOOK HAS NOT COVERED THE INFORMATION YOU SENT ME. THEY JUST STATED TO ENTER THE CODE BUT DIDN'T STATE EXACTLY WHERE I SHOULD PUT THE CODE SO I JUST PUT IN AT THE BOTTOM. YOUR ANSWER FIXED THE PROBLEM AND IT WAS IMMEDIATELY OBVIOUS. I HOPE THE BOOK DOESN'T HAVE MANY OF THESE KIND OF OMISSIONS.
THANKS
ANDYLITES





Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED EXPLANATION WHY CODE GIVES ERRORS andylites BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 2 March 24th, 2009 10:19 AM
Program Code Errors ed123 Beginning PHP 0 September 8th, 2007 03:53 AM
code explanation Amitava Deewan Access VBA 2 August 8th, 2005 03:26 PM
Printing Errors / Example Code Fire BOOK: Access 2003 VBA Programmer's Reference 0 April 12th, 2005 02:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.