Solved

# Passing a Procedure after creating a procedure

Posted on 2004-11-14
169 Views
After creating an average function procedure that takes a decimal and return the results as a string how do I create another procedure that passes the decimal back to the average function
0
Question by:thimss2

LVL 22

Expert Comment

You pass a decimal to average, and you need to pass the decimal back to average? Could you clarify what you want?
0

Author Comment

I have created this functionn:
Public Function AWage(ByVal dWages as Decimal, By Val nEmpls as Integer) as String

Dim dWages as Decimal
Dim nEmpls as Integer

Return CStr(dWages/nEmpls)
End Function

Now I need to create a procedure that takes a decimal and integer and passes them to the Average function above

Thanks
0

LVL 22

Expert Comment

Public Sub Average(ByVal dWages as Decimal, By Val nEmpls as Integer)
AWage(dWages, nEmpls)
End Sub

?

0

Author Comment

Re: I need to create a procedure that takes a decimal and integer and passes them to the Average function above
This is what I have come up with on my own.  I need some Feedback.

' called procedure which decides the passing mechanism
Sub DisplayInfo(AWage as string)
Messagebox.Show(AWage)
End Sub

'calling procedure which passes the data into the average function above(AWage)
Sub avg1(dWages, nEmpls) Handles Button.Click1
Dim V as string
V= CSTR(dWages/ nEmpls)
DisplayInfo(V)
End Sub

0

LVL 22

Accepted Solution

Mm, you are a beginner :-)

I assume that you have a Button instance, and you would like the Average function to be called after a button has been pressed. Try it like:

Protected WithEVents Button1 as Button

' called procedure which decides the passing mechanism
Sub DisplayInfo(ByVal AWage as string)
Messagebox.Show(AWage)
End Sub

'calling procedure which passes the data into the average function above(AWage)
Public Function Average(ByVal dWages as Decimal , ByVal nEmpls as ) as String
Return (dWages/ nEmpls).ToString()
End Function

Private Sub Button1_OnClick(sender as Object, e as EventArgs) Handles Button1.Click
DisplayInfo(Average(1.2, 4))
End Sub
0

## Featured Post

XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…