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:13 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.

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

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 24th, 2009, 05:04 AM
Authorized User
 
Join Date: Mar 2009
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try it


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


'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

End Class
 
Old March 24th, 2009, 10:19 AM
Registered User
 
Join Date: Mar 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Red face pratikasthana

Quote:
Originally Posted by pratikasthana View Post
Try it


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


'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

End Class

DEAR pratikasthana:
THANKS FOR THE INFO. THIS IS SO BASIC, BUT I AM JUST BEGINNING AND THE BOOK HAS NOT COVERED THE SUBJECT OF YOUR REFERRENCE OF PLACEMENT OF END CLASS. I JUST ENTERED IT AT THE BOTTOM. I GUESS I SHOULD HAVE SEEN IT MYSELF.
THANKS:
ANDYLITES





Similar Threads
Thread Thread Starter Forum Replies Last Post
can you help me find the errors with the code ousys Java Basics 7 June 15th, 2007 07:18 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.