473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Passing parameters in VB 2005!!

Nab
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..?
--
UK
Oct 17 '06 #1
2 2006
"Nab" <Na*@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.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

Oct 17 '06 #2
Nab
It's possible. Thanks for the thought and it's nice to know that Microsoft
has not changed the law of passing parameters.
--
UK
"Mitchell S. Honnert" wrote:
"Nab" <Na*@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.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


Oct 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
1
by: Maria | last post by:
Hello! I am new to Crystal reports an I have problems passing parameters form outside to Crystal report an creating a report with data from more than one table This is the problem: I have to...
2
by: Carlos | last post by:
Hi all, I am familiar with passing parameters to a thread function using C++, but I needt to learn it using C#. Can someone shed some light on how to do this? Code snippets will be great to show...
2
by: Akira | last post by:
Hello. I'm having problem with passing parameters from .aspx file to user control. Could anyone tell me how to pass parameters from .aspx file to user control(.ascx) and how to recieve parameters...
0
by: Paul Allan | last post by:
I am new to ASP.net (intermediate ASP developer). I am developing a ASP.net web application and I am having some difficulty calling and passing parameters to a function that is declared in my...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
4
by: David Freeman | last post by:
Hi There! I'm just wondering if there's a way to pass parameters (as if you were passing parameters to a ASCX web control) when calling an ASPX page? e.g. MyDetailsPage.UserName = "david" ...
1
by: Gert Wurzer | last post by:
Hi! I have an asp.net 2.0 web application that uses an iframe to access another asp.bet 2.0 webapp via https. I've already found a working prototype solution to create a dynamic iframe taking...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.