Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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