We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,379 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Help with coding an application that will calculate the square and square root

How do I go about coding the 'Calculate button' so that when a user is prompted to input a number into a Input box it will will calculate the square and square root of it?

This is what I have so far. I'm pretty sure about the first part, but am confused about the square root part.

Private Sub cmdCalc_Click()
	‘calculate square of a number
	lblTsquare.Caption=txtNumber^2
	‘calculate square root of a number
	txtNumber.Text = Sqr(txtNumber.Text)
End Sub
2
Contributors
4
Replies
14 Hours
Discussion Span
3 Years Ago
Last Updated
5
Views
Question
Answered
EntangledDesi
Newbie Poster
22 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

you should get correct output with your code. there is nothing wrong with it.

debasisdas
Posting Genius
6,968 posts since Feb 2007
Reputation Points: 722
Solved Threads: 457
Skill Endorsements: 20

So it is

txtNumber.Text = Sqr(txtNumber.Text)

and not

lblTroot.Caption=Sqr(txtNumber.Text)

?

EntangledDesi
Newbie Poster
22 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

*accidently posted twice

EntangledDesi
Newbie Poster
22 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Figured it out :D It's

Private Sub cmdSquare_Click()
    'calculate square of a number
    lblTSquare.Caption = txtNumber ^ 2
    'calculate square root of a number
    lblTroot.Caption = Sqr(txtNumber.Text)

End Sub
EntangledDesi
Newbie Poster
22 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 3 Years Ago by debasisdas

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0680 seconds using 2.66MB