Return A String From A Function

Jun 27, 2012

I have a class in this class i call a function which should return some string the class connects to an ftp server and list the directory and returns the filenames of the dir.

Code:

Public Function GetFileList(ByVal host As String, ByVal username As String, ByVal password As String, ByVal currentdirectory As String) As List(Of String)
Dim oFTP As FtpWebRequest = CType(FtpWebRequest.Create(host & currentdirectory),

[CODE]..........

So this should return all filenames of that directory

like:

Data1.xml

Data2.xml

Data3.xml

Now i have a form with a listview where i want to call this function and get the files of the "olist"

Code:

Return oList

HOW CAN I DO THAT? i mean how would my sub look like on my form where i want to call that function?

View 2 Replies


ADVERTISEMENT

Return String From C++ Function?

Nov 8, 2011

I am trying to call C++ function from VB.Net code which returns string using PInvoke, but it is returning only single character.

C function Declaration
extern "C" __declspec(dllexport) LPSTR Get_GetDescription(HANDLE)
C function Defination
LPSTR Get_GetDescription(HANDLE resultBreakDown){

[Code].....

View 1 Replies

.net - Function To Accept List(Of String), Array & String And Similarly Return List(Of String)?

Jul 29, 2011

I want the Function to accept List(Of String), Array & String and similarly return List(Of String), Array & String respectively. The Function simply adds a string (month) to the input collection. I just want to use it for string, array and list with needing to think of conversions.

[Code]...

View 2 Replies

.net - Return A String Array From A Function Without Initialising It First?

Dec 10, 2009

Public Function Foo() as String() Dim bar As String = {"bar1","bar2","bar3"}

Return bar End Function

My situation is similar to the code sample above where I'm returning a string array from a function.

What I would like to do is just return the string array without having to declare a variable first and then return the variable.Something like this, although this obviously doesn't work:

Return {"bar1","bar2","bar3"}

Is it possible to do this, I can't seem to find a method that works?

View 2 Replies

Exit Function Or Return String.empty?

Sep 9, 2009

I have the following piece of code: trying to use this in 2.0 framework. getting error for not having a return statement before exit function.[code]...

View 4 Replies

String.Format Function Return Only Left 10 Characters?

May 2, 2011

For years I never had trouble with this String. Format function until today when I got a value longer than 0 characters and the function returned all the characters in the string instead of just ten. Now sometimes I get less than ten characters so I can't use the substring with out getting an error. I can try the left function but I was hoping there was a solution with the Format function.

View 6 Replies

Function Which Take String (alfanumeric+special Char) As Input And Return Serial Key

May 6, 2010

i want to generate a serial key which depend on system harddisk manufacture id ...

so Is any function which take string of alfanumeric + special char as input and after encrypted return output as unique serial key / product key...

View 10 Replies

Visual Studio 2010 - .NET Function As String, Will Return False Be A Boolean?

Sep 21, 2011

I have a HTTP class that gets content from URL's, POST's content to URL's etc and then returns the raw HTML content.In the function inside of the class it detects if there is a HTTP error and if so I would like to return false but will this work if I have declared the function to return a String?

Code Sample of what I am trying to do (Note the Return Content & Return False if a HTTP error code is detected)Public Function Get_URL(ByVal URL As String) As String

[Code]...

View 1 Replies

Color.FromName To Return A Solid Black Color When The Function Doesn't Recognize Any Text In The String Passed To It?

Jan 29, 2012

[URL] That way if the string that is not recognised that is passed to Color.FromName it returns a SolidColor of

Color.Black = Color.FromARGB(255,0,0,0)

That way, Forms and controls that only support SolidColors are supported.Installing VB6 on Windows 7?

View 15 Replies

Return An (Anonymous Type With A Function) From A Function?

Mar 3, 2011

Just so it's known, this question is mostly academic, even though I tried to use the concept in a real-world solution. I realize the example is contrived, but I believe the concept is valid.I want to write some fluent code like this:

[code]...

I realize that I can't force an anonymous type into a specific type (like implementing an interface or some other class), and I don't want the overhead of defining a specific class just to match my desired fluent name with the actual method name. So I was able to make the code work like this:

copy(my_first_file).to.Invoke(my_second_file)So there is no IntelliSense or type awareness there, and I have to include the Invoke in order to have the method run. How can I get more type safety and exclude the Invoke method, under these constraints: Anonymous Type returned from Method No additional classes or interfaces Preferably, I do not want to pass in another parameter to the copy() method that tells what type to return, unless copy becomes a generic method (but I think that means defining another class/interface, which I don't want to do)

View 3 Replies

.NET Function Return Value?

Jun 15, 2011

Possible Duplicate: VB.NET Function Return If I have a function that returns a boolean, what is the difference between:Return False and Function = False

View 2 Replies

Function Does Not Return Nothing?

Feb 12, 2010

take a look at the following Code:

Private Sub btnDebug_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDebug.Click
Dim d As Date

[Code]....

The Funtion ZZNull always returns Nothing, so IsNothing(d) in the calling method should evaluate to True.

But it does not !

When you run these lines, then you will see that IsNothing(d) evaluates to False

View 7 Replies

Get A Function's Return Value?

Jan 14, 2012

In the documentation of FileInfo.Create Method it says:

'Declaration
Public Function Create As FileStream
'Usage

[code].....

View 7 Replies

How To Use A Function's Return Value

Mar 8, 2009

So the program I am writing validates the controls on the page on button_click.

I want to write a function which checks which step the program is at (0-7) then return something depending on whether or not it validated.

My plan was to return the control which was not valid.

Private Function ValidateInputs() As Control
Select Case wizardStep
Case 0

[Code].....

1. could I return the names off all the controls which did not validate?

2. should I be returning a control type or would something like a string be better?

View 3 Replies

Return More Than One Value From A Function?

Mar 1, 2012

One over time hours and one week's pay @10 hourly pay. I wanted to display those two in two listboxes 1 and 2.

Public Class Form1
Dim overTimeHours As Double
Dim weekPay As Double

[Code].....

View 4 Replies

Return More Than One Value From The Function?

Jun 2, 2009

how return four value from a function. In general function will return single value but here i am going to return four different values. If possible please tell me how to store the function return values.

[Code]...

View 4 Replies

Return NaN From A Function?

Oct 5, 2010

I've created my own version of HexToDec() to properly handle the negative flag. I saw other versions online that used "Not(value)" to do the Pos/Neg inversion, but that does not generate the proper value... No, it's not the most elegant my any means. But I couldn't find anything online that actually worked.

Long story short, I want to return NaN in the case that the function is passed a string that is not a valid hex string...

How do I do that? Everything I've tried generates a compiler error... (assign return value to double.nan, assign return value to non-numeric, etc)

Existing function is below:

Function HexToDec(ByVal hexStr As String, Optional ByVal signed As Boolean = False) As Long
Dim lngFinal As Long

[Code].....

View 11 Replies

Return Value Of A Function?

Apr 14, 2009

I get the below warning [code]...

To solve it I put a return statement "Return 1" in the code.

View 2 Replies

.net - Can't Return Dictionary(Of String, String) Via GET Ajax Web Request, Works With POST

Jun 23, 2009

I have the following web method:

<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True, XmlSerializeString:=True)> _

[Code].....

I wanted to use HttpGet here so that the result can be cached.

I tried every variation of calling this, but no luck. Is this possible with GET?

View 2 Replies

.net - WCF Function Won't Return Stream?

May 11, 2011

So I have a function which returns a pdf stream. The calling procedure gets the stream and writes it to disk Normal VB code is as follows:

[Code]...

View 2 Replies

CLR - Function/Operator Without Return Value?

Sep 4, 2009

I've create a new project, and set treat all warnings as errors in the compile tab.All the other warnings seem to be treated as errors, except the one which I'm interested in "Function/Operator without return value".I have a simple function within a class, which does not show an error if I do not add a return statement to that function. I have read in many places that VB.Net returns a "hidden" default value if the returns statement is forgotten.My software went out to production where an overloaded function was missing a return statement, which wasn't highlighted due to the above.

View 20 Replies

Function Doesn't Return A Value?

Feb 18, 2012

[code]i want to change password for the users [code]

View 14 Replies

Function To Return Array?

Aug 5, 2011

Before adding rows to a table I am evaluating the SSN number. These will later be flagged for correction so I am setting a datatable column to true or false if it passed muster or not.

I wrote a function to check the number and make the determination plus pad it with zeros and hyphens where they should be. My problem is I want to return the results in an array. I am getting system.string[] as the return value.[code]...

View 14 Replies

Function Without Return Type?

Dec 23, 2010

In my project (which I inherited from someone) there are a lot of functions like:

Public Function DoSomething(ByVal s As String)
' Do something to public properties
End Function

And they are called like this:

DoSomething(s)

So the return value is ignored (which is object, as I see in the docs). Is it safe to change all these functions to Subs? Could I break something which isn't so obvious?

View 2 Replies

Function Won't Return An Array

Jun 1, 2010

I'm trying to write a function that returns an Array that I can pass into a String.Format[code]...

View 3 Replies

How To Get 2 Return Values In One Function

Mar 26, 2012

i want to get two output values in one Function is't possible ?i am just using String data type and split the values.but have any other easy way to get two output values actually i want to checking a folder how many jpg files are Horizontal and vertical [code]finally i split the values with "|" character.have any other options to get two values as separate in one functions.i have no moew idea about Dictionary,

View 2 Replies

No Return Keyword For Function In .NET?

Aug 5, 2011

I've been doing some code review and this code seemed weird to me since it doesn't have any return statement:Protected Function AddZero(ByVal vsInput As String) As String

If Len(vsInput) = 1 Then
AddZero = "0" & vsInput
Else
AddZero = vsInput
End If
End Function

View 2 Replies

No Warning In .NET When Function Has No Return?

Feb 25, 2010

warnings got me thinking about old issues that always goofed me up when I was writing more VB.NET code.One of them was the fact that the compiler didn't warn if you declared a Function but never did an explicit Return statement or assign to the Function name. Running Visual Studio 2008, I just made a small experimental project, and it seems as though the behavior has never been fixed.I created a Visual Basic Console application, with the following code:

Module MainModule
Sub Main()
Dim test As Boolean = TestWarning()[code].....

I also went into the Project Settings and turned On Option Strict and Option Explicit.I also set the Warning Configurations so that "Function/Operator with no return value" was set to Error.I compiled the project and got no warning, and no error on the TestWarning() Function. This seems like a great place to put a warning, because it will default to False, and you may have simply forgotten to do a return. C# will error without a return statement. I thought that VB.NET did the same thing with the "Function/Operator with no return value" configuration. Is this a bug, or is there something I'm missing?

Edit: Further Experimentation

Function TestWarning() As Boolean
If DateTime.Now.DayOfWeek = DayOfWeek.Monday Then
Return False[code].....

If, and nothing in the Else, there is also no Warning/Error. It will simply take the default, even though you likely intended (via programming style) to have an explicit return. In this case, I explicitly returned False (which is the default for Boolean), so it's likely a hidden bug that I should have returned True in the Else.

View 4 Replies

Return An Array From A Function?

Nov 4, 2011

I want to return an array from a function.dt is a DataTable that is global

HTML
Dim dr As DataRow
For x As Integer = 0 To adoc.GetUpperBound(0)
dr = ds.Tables(0).NewRow()

[code].....

I'm definitely missing something here. I am trying to return an array forn the sql statement, chich I can reference as abom() in the original source.The ultuimate goal is to manually populate dt.

View 14 Replies

Return An Error From A Function?

Jan 7, 2009

I have a function that returns a double. If in the function I decide the value is invalid, is there any way to return "error" instead of a double? Of course I could pass a boolean by reference and set it false and then check for that back in the calling function, but that seems awkward.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved