Click here to Skip to main content
15,905,563 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Refresh font folder Pin
Ajay.k_Singh15-Sep-08 0:01
Ajay.k_Singh15-Sep-08 0:01 
QuestionAutoCompleteStringCollection Pin
CodingYoshi14-Sep-08 18:44
CodingYoshi14-Sep-08 18:44 
AnswerRe: AutoCompleteStringCollection Pin
Ashfield14-Sep-08 21:05
Ashfield14-Sep-08 21:05 
GeneralRe: AutoCompleteStringCollection Pin
CodingYoshi15-Sep-08 3:26
CodingYoshi15-Sep-08 3:26 
AnswerAutoCompleteStringCollection Pin
AshimD6-Dec-08 3:34
AshimD6-Dec-08 3:34 
QuestionVS 2005 resources Pin
Rafone14-Sep-08 8:38
Rafone14-Sep-08 8:38 
QuestionMaking a function or a sub Pin
Maffyx14-Sep-08 7:34
Maffyx14-Sep-08 7:34 
AnswerRe: Making a function or a sub Pin
Scott Dorman14-Sep-08 7:47
professionalScott Dorman14-Sep-08 7:47 
Maffyx wrote:
I want to put it all into a function or a sub. I'm not sure what the difference is but I want it to have an input, use the code, and then return what the code says. Is something like this possible? H


Ahhh...one of the things I really disliked about VB/VB.NET was that it makes such a distinction between a "sub" and a "function". This difference is really just a syntax difference that the language exposes, not a real difference in the runtime itself.

A "sub" and a "function" are both part of a concept generally known as methods. A method can have a "return type" or can return nothing, in which case it is said to have a "void" return type. The return type is the output of the method. In all cases a method can have one or more parameters specified, which are the inputs to the method.

Most languages do not make a distinction between a method that has a real return type or a void return type. VB/VB.NET, however, does. A "sub" in VB/VB.NET is simply a method that has a void return type while a "function" is a method that has a real return type.

You actually answered your own question when you asked it...you specifically stated that you "want it to have an input...and then return..." so you are looking for a "function" that has a real return type.

As far as taking your code and wrapping it in a function, you need to decide what your inputs should be and what your return type should be. Looking at your sample code it looks like you are setting Label11.Text so you probably want to return a String value and you probably want a String return type as well.

Your code should end up looking something like this:
Public Function F1 (filePath as String) As String
Begin
   ' Your code goes here...
 
   ' This is how you actually return a value from a function. In this
   ' case the function returns a String, so you set the name of the 
   ' function equal to the value you want returned.
   F1 = "text"
End


Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

GeneralRe: Making a function or a sub Pin
Maffyx14-Sep-08 8:16
Maffyx14-Sep-08 8:16 
GeneralRe: Making a function or a sub Pin
Scott Dorman14-Sep-08 8:23
professionalScott Dorman14-Sep-08 8:23 
QuestionGet # of items in recycle bin Pin
jacobjordan13-Sep-08 12:28
jacobjordan13-Sep-08 12:28 
AnswerRe: Get # of items in recycle bin Pin
jzonthemtn13-Sep-08 14:58
jzonthemtn13-Sep-08 14:58 
GeneralRe: Get # of items in recycle bin Pin
jacobjordan13-Sep-08 16:24
jacobjordan13-Sep-08 16:24 
QuestionXML generating problem Pin
pbbhatt12-Sep-08 20:17
pbbhatt12-Sep-08 20:17 
AnswerRe: XML generating problem Pin
Dave Kreskowiak13-Sep-08 5:04
mveDave Kreskowiak13-Sep-08 5:04 
AnswerRe: XML generating problem Pin
Ashfield14-Sep-08 21:07
Ashfield14-Sep-08 21:07 
QuestionPrograaming in Visual Basic.Net Pin
dereck12-Sep-08 19:41
dereck12-Sep-08 19:41 
AnswerRe: Prograaming in Visual Basic.Net Pin
Garth J Lancaster12-Sep-08 19:53
professionalGarth J Lancaster12-Sep-08 19:53 
JokeRe: Prograaming in Visual Basic.Net Pin
Paul Conrad13-Sep-08 5:06
professionalPaul Conrad13-Sep-08 5:06 
GeneralRe: Prograaming in Visual Basic.Net Pin
Garth J Lancaster13-Sep-08 5:22
professionalGarth J Lancaster13-Sep-08 5:22 
GeneralRe: Prograaming in Visual Basic.Net Pin
Paul Conrad13-Sep-08 5:25
professionalPaul Conrad13-Sep-08 5:25 
GeneralGO GARTH! GO GARTH! Pin
leckey13-Sep-08 15:35
leckey13-Sep-08 15:35 
GeneralRe: GO GARTH! GO GARTH! Pin
Garth J Lancaster13-Sep-08 18:04
professionalGarth J Lancaster13-Sep-08 18:04 
AnswerRe: Prograaming in Visual Basic.Net Pin
Dave Kreskowiak13-Sep-08 5:22
mveDave Kreskowiak13-Sep-08 5:22 
QuestionHow to copy a DAT file from one machine to another within a workgroup with using code in vb6 Pin
D.Manivelan12-Sep-08 19:08
D.Manivelan12-Sep-08 19:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.