473,396 Members | 1,996 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,396 software developers and data experts.

Why a data after the parameter list?

Hello

When creating a function or sub procedure what purpose does the data type
declaration outside of the parameter list after the parenthesis on the end
serve?
for example Public Sub mypgm(Byval fld1 as integer) as string
Sep 19 '07 #1
5 1050
=?Utf-8?B?d2lubGlu?= <wi****@verizon.comwrote in
news:3B**********************************@microsof t.com:
When creating a function or sub procedure what purpose does the data
type declaration outside of the parameter list after the parenthesis
on the end serve?
for example Public Sub mypgm(Byval fld1 as integer) as string
The line above is invalid because sub procedures don't return anything.

Functions on the otherhand return data, and it's used to declare the type
of data being returned.
Sep 19 '07 #2
It's the return value of the function. Your example is illegal
syntax, since a Sub does not return a value.

Correct syntax would be:
Public Function MyPgm(ByVal fld1 As Integer) As String

The function MyPgm returns a String.

On Wed, 19 Sep 2007 08:12:02 -0700, winlin <wi****@verizon.comwrote:
>Hello

When creating a function or sub procedure what purpose does the data type
declaration outside of the parameter list after the parenthesis on the end
serve?
for example Public Sub mypgm(Byval fld1 as integer) as string
Sep 19 '07 #3
On Sep 19, 11:12 am, winlin <win...@verizon.comwrote:
Hello

When creating a function or sub procedure what purpose does the data type
declaration outside of the parameter list after the parenthesis on the end
serve?
for example Public Sub mypgm(Byval fld1 as integer) as string
It's purpose is to allow a method to return a value after it is
finished processing.

For Example:

////////////////////
Public Function IsUserValid(ByVal userName As String) As Boolean
If (the user is valid) Then
Return True
Else
Return False
End If
End Function

Public Sub Foo()
Dim isValid As Boolean = IsUserValid("Seth Rowe")
If isValid Then
MsgBox("Seth Rowe is a Valid User")
Else
MsgBox("Seth Rowe is not a Valid User")
End If
End Sub
///////////////////

The code to check whether a given name is a valid user has been
encapsulated into the IsUserValid method. Any other method can now
pass in a string to this function and will receive a boolean value
from the method that will indicate whether the user is, or isn't,
valid. Other examples are methods that might construct an object, such
as a DataTable. In general, the constructed DataTable will be created
in the method and returned as a return value (Public Function
BuildDT() As DataTable).

Thanks,

Seth Rowe

Sep 19 '07 #4
Winlin,

Looking at the other answers shows that it has a lot of possibilities.
Forget VB6 that was time consuming finding itself the correct type.

However beside the answers you got already, don't forget overloading. By
telling te types you can create more methods, with almost the same code.

Cor

"winlin" <wi****@verizon.comschreef in bericht
news:3B**********************************@microsof t.com...
Hello

When creating a function or sub procedure what purpose does the data type
declaration outside of the parameter list after the parenthesis on the end
serve?
for example Public Sub mypgm(Byval fld1 as integer) as string
Sep 20 '07 #5
However beside the answers you got already, don't forget overloading. By
telling te types you can create more methods, with almost the same code.
I don't think overloading applies here as you can't overload based on
return type.

Thanks,

Seth Rowe
Sep 20 '07 #6

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

Similar topics

0
by: Monica Ferrero | last post by:
Hi! I'm not sure if this is the most adequate mySQL list for this post. If not, please indicat me which one I should use... I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
9
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
2
by: mast2as | last post by:
Hi there, for a long time I've been trying to think of way of saving different data of different types using one single class (well 2 in reality, a class for the data, and 1 class for a list of...
3
by: SAL | last post by:
Hi, I have Microsoft Enterprise Library 2005 installed on my local system. I'm developing in C# using Visual Studio 2003 IDE with framework 1.1. I am automating a process that will use a DLL...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
3
by: =?Utf-8?B?S3VsZGVlcCBWaWpheWt1bWFy?= | last post by:
Language: C#.NET 2.0 Technology: ASP.NET 2.0 Database: Oracle 10g Hi All, Could any one of you please suggest the BEST method to: 1. Fetch data from a very large .csv file (around 8 MB) and...
7
by: limperger | last post by:
Hello everyone! Just in case anyone has any wonder about this... I have a parameter query that searchs for records that have the particular word provided by the user in a memo field (using the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.