Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

VB.Net Procedures


  • Please log in to reply

#1
Sparklies

Sparklies

    Member

  • Member
  • PipPip
  • 11 posts
I am trying to write a program where you enter 2 numbers (Arg1 and Arg2) and then a MessageBox pops up that tells you what Arg1 raised to Arg2's is.

All I can come up with is "Arggggggggggggggggghhhhhhhhhhh!" :whistling: :blink:

Below is my code.



Option Strict On
Option Explicit On 

Public Class PowerForm
	Inherits System.Windows.Forms.Form

Private Function Power() As Double
		Dim Sum As Double
		Dim Arg1 As Double
		Dim Arg2 As Double

		Arg1 = CInt(txtArg1.Text)
		Arg2 = CInt(txtArg2.Text)
		Sum = Arg1 ^ Arg2
		Return (Sum)

End Function

Private Sub btnCall_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles btnCall.Click
		Dim Sum As Double
		Power()
		MsgBox(Sum)
End Sub

End Class



When I run the program, the MessageBox shows an answer of zero.

Can someone tell me what I am doing wrong?



Thanks...
  • 0

Advertisements


#2
SpencerClark

SpencerClark

    New Member

  • Member
  • Pip
  • 4 posts
hi there


I think you might need to convert the text box values to doubles rather then integers...................


Spence
  • 0

#3
Ctrl_Alt_Del

Ctrl_Alt_Del

    Member

  • Member
  • PipPip
  • 74 posts
Option Strict On

Option Explicit On 



Public Class PowerForm

	Inherits System.Windows.Forms.Form



Private Function Power() As Double

		Dim Arg1 As Double

		Dim Arg2 As Double



		Arg1 = Cdbl(txtArg1.Text)

		Arg2 = Cdbl(txtArg2.Text)

		Power = Arg1 ^ Arg2

		



End Function



Private Sub btnCall_Click(ByVal sender As Object, ByVal e As System.EventArgs) _

Handles btnCall.Click

		Dim Sum As Double

		Sum = Power()

		MsgBox(cstr(Sum))

End Sub



End Class




  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP