|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Passing parameters in VB 2005!!that you only need to pass the input parameter. The output parameter's value will be returned without the need to pass it as was the case in the previous version of VB e.g. VB .Net 2003. Here's the procedure in the web service: Public Sub Convert2Dollar(ByVal euroAmount As Double, ByRef usDollarAmount As Double) Dim exchangeRate As Double exchangeRate = 10 / 6 usDollarAmount = euroAmount * exchangeRate End Sub Here's how i passed an input parameter in a button's click procedure (and it worked!!): Dim myEuro As Double myEuro = CDbl(txtEuro.Text) Dim objConverter As New localhost.Service lblDollar.Text = CStr(objConverter.Convert2Dollar(myEuro)) Does anyone know why this should work..? -- UK
Show quote
Hide quote
"Nab" <N**@discussions.microsoft.com> wrote in message It's not working for me. I copied your code into a test form and get the news:EC7020BC-8239-4D6C-9040-1F3920FC726E@microsoft.com... >I have just tried to pass parameters to a procedure in VB 2005 and realised > that you only need to pass the input parameter. The output parameter's > value > will be returned without the need to pass it as was the case in the > previous > version of VB e.g. VB .Net 2003. > > Here's the procedure in the web service: > Public Sub Convert2Dollar(ByVal euroAmount As Double, ByRef usDollarAmount > As Double) > Dim exchangeRate As Double > exchangeRate = 10 / 6 > > usDollarAmount = euroAmount * exchangeRate > End Sub > > Here's how i passed an input parameter in a button's click procedure (and > it > worked!!): > > Dim myEuro As Double > myEuro = CDbl(txtEuro.Text) > Dim objConverter As New localhost.Service > > lblDollar.Text = CStr(objConverter.Convert2Dollar(myEuro)) > > Does anyone know why this should work..? following error on the reference to Convert2Dollar... "Argument not specified for parameter 'usDollarAmount' of 'Public Sub Convert2Dollar(ByVal euroAmount As Double, ByRef usDollarAmount As Double)'" Are you sure you don't have an overload of Convert2Dollar that only has a single parameter of type Double? That's the only thing that makes sense to me given that you are not getting an error. Also, some unsolicited advice. I would change your Sub to a Function. You have a single input and a single output, a textbook use for a Function. So, your code would look like this... Public Function Convert2Dollar(ByVal euroAmount As Double) As Double Dim ExchangeRate As Double = 10 / 6 Return euroAmount * ExchangeRate End Function If this is more than just a sample to demonstrate your problem, you might also consider passing in the exchange rate. Good luck. - Mitchell S. Honnert Show quoteHide quote > > > -- > UK It's possible. Thanks for the thought and it's nice to know that Microsoft
has not changed the law of passing parameters. -- Show quoteHide quoteUK "Mitchell S. Honnert" wrote: > "Nab" <N**@discussions.microsoft.com> wrote in message > news:EC7020BC-8239-4D6C-9040-1F3920FC726E@microsoft.com... > >I have just tried to pass parameters to a procedure in VB 2005 and realised > > that you only need to pass the input parameter. The output parameter's > > value > > will be returned without the need to pass it as was the case in the > > previous > > version of VB e.g. VB .Net 2003. > > > > Here's the procedure in the web service: > > Public Sub Convert2Dollar(ByVal euroAmount As Double, ByRef usDollarAmount > > As Double) > > Dim exchangeRate As Double > > exchangeRate = 10 / 6 > > > > usDollarAmount = euroAmount * exchangeRate > > End Sub > > > > Here's how i passed an input parameter in a button's click procedure (and > > it > > worked!!): > > > > Dim myEuro As Double > > myEuro = CDbl(txtEuro.Text) > > Dim objConverter As New localhost.Service > > > > lblDollar.Text = CStr(objConverter.Convert2Dollar(myEuro)) > > > > Does anyone know why this should work..? > It's not working for me. I copied your code into a test form and get the > following error on the reference to Convert2Dollar... > "Argument not specified for parameter 'usDollarAmount' of 'Public Sub > Convert2Dollar(ByVal euroAmount As Double, ByRef usDollarAmount As Double)'" > > Are you sure you don't have an overload of Convert2Dollar that only has a > single parameter of type Double? That's the only thing that makes sense to > me given that you are not getting an error. > > Also, some unsolicited advice. I would change your Sub to a Function. You > have a single input and a single output, a textbook use for a Function. So, > your code would look like this... > > Public Function Convert2Dollar(ByVal euroAmount As Double) As Double > > Dim ExchangeRate As Double = 10 / 6 > > Return euroAmount * ExchangeRate > > End Function > > If this is more than just a sample to demonstrate your problem, you might > also consider passing in the exchange rate. > > Good luck. > > - Mitchell S. Honnert > > > > > > > > -- > > UK > > >
how do you use Class to hold global variables?
Installed, but where is it? VB.NET Datagrid with pictures VB equivalent of this C# code Full qual. name of current method Writing Data In Tabular format in Text File. What framework is running in this scenario? VBNET2005 : Manipulating MS Access tabledefinitions in VB.NET -> Create, Copy and Drop Table. Showing Form in New Thread? db connections and text boxes |
|||||||||||||||||||||||