Return Two Parameters With Function?
Jul 6, 2009is there a way to return two parameters with function ?something like
Private Function blah() as string
Dim hl as String = "Hello"
dim tr as String = "There"
[code]....
is there a way to return two parameters with function ?something like
Private Function blah() as string
Dim hl as String = "Hello"
dim tr as String = "There"
[code]....
Dim oList as new Hashtable
oList.Add("1","Value1")
How can I create a a function to return my objects like the above one.
[code].....
is there a way to get the GET parameters and POST parameters in just one function or Collection in ASP.NET? Like using $_REQUEST in PHP? I'm using VB.NET.
View 3 RepliesI'm currently working with a client's VB.Net code, which was developed for them by a small development shop a few years ago and which they purchased and have been maintaining and uprgrading since. This client's primary developer is out on indefinite (likely permanent) medical leave and I'm now filling in until they bring in a full timer (as I'm a contractor here). My current task is to add some functionality to a the VB.Net code they purchased. I'm finding practices and techniques in the code that absolutely baffle me and can't make the code do what I want. I'm starting to wonder if it's me and was hoping to get some thoughts on the code I've encountered.
For example: Setting a variable to accept the result of a function by calling the function with many parameters, clearing the parameters in the function, setting them to some value, calling another function with those new values, then never using the values returned by the functions. I'll add a code snippet in the first comment since this is already getting long.
What I want is to open a new popup from the server side, this pop up has a form with three fields, and then return this three fields to the parent page. But I want this fields in the server side, in the VB.NET code. Is this possible?
View 2 RepliesJust 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)
I am trying to use the right function in VS 2008. I am simply trying to get the right 5 characters of a string.
VendorID = Right(cboVendors.Text, 5)
I am getting an error when I type that:
Error1'Public ReadOnly Property Right() As Integer' has no parameters and its return type cannot be indexed.
i want to get all available midi device by name. i found this: Declare Function midiOutGetID Lib "winmm.dll" (ByVal hMidiOUT As Integer, ByRef DeviceName As String) As Integer
but: how do i get these informations now?
where the VS debugger refuses to show certain field types including dates.My call stack contains FunctionA which calls FunctionB. FunctionB has about 45 parameters and many of them are dates.When I step into functionA,
1. the debugger refuses to show a date variable when you hold the mouse over it. It just shows {Date} instead of a value
2. If you do quick watch on that same variable, it also just shows {Date} instead of a value
3. If I do ?variablename in the immediate window, I get "System Error &H80131c23&"
When I comment out the call to functionB, the date variables all show correctly in all the above methods. I will stress that the code has not yet reached functionB, just its very existence in code screws up the debugger.I'm thinking this is a memory issue and maybe vs debugger can't cope with a huge function stack frame dataspace.devenv is only using 268Meg of ram on a 2Meg box, with not much else running. Thats reasonable for this size of project.
I use this code to invoke a function from a string, which I build in my application:
Public Class Form1
Dim f As New Foo
Dim methodName As String
Dim result As Object
[code]....
I'm writing a VB.NET function with a ton of overloads. I've seen that most .NET functions have parameter descriptions in IntelliSense. For example, when typing in String.Compare(, IntelliSense says Compares two specified System.String objects and returns... you get the idea. This description changes and you click through different overloaded versions of the same functions. When you start typing in something for a parameter, it describes the parameter you're currently inputting as well. Example: strA: The first string to compare..
View 5 RepliesI have to create a program that finds the total cost for pizza, fries, and soft drinks, and places that in a list box. So far, though, I'm stuck. I have this code so far:
Public
Class frmBill
Private
Sub btnTotal_Click(ByVal
sender As System.Object,
[Code] .....
The errors that I am getting are:
"Argument not specified for parameter 'D' of Public Function totalBill(P As Double, F As Double, D As Double)
"Argument not specified for parameter 'F' of Public Function totalBill(P As Double, F As Double, D As Double)
"Argument not specified for parameter 'P' of Public Function totalBill(P As Double, F As Double, D As Double)"
i have a function that i can't tell how many parameters i need to pass into it (could be anywhere between 0-10+), how do i handle this ?
View 7 Repliesi am using XML as database, so updating or inserting diffrent XML's currently i am manage a seprate class for seprate XML file, this process consuming my lot of time, i want to create a genrelize class. currently according to the XML need i am sending two, three, four or five parameter in my function.
now i want to send array of the parameter to my function, so becoz of this thing i could mange all of my functions via a single class...
i am sending u the example what currently i use now...
Public Function Update(ByVal Item_ID As Long, ByVal ProductName As String, ByVal Price As Long, ByVal Path As String) As Long
Try
[Code].....
Can we pass parameters to a function using delegates
Private Sub UpdateLabel(byval text as string)
If Me.Label1.InvokeRequired Then
Me.Label1.Invoke(New MethodInvoker(AddressOf UpdateLabel))
Else
Label1.Text = text
[Code]...
I need to convert the following C# code to VB.NET:
public bool TryGetRewriteMatch(UrlContext url, out RedirectMatch match)
{
// NOTE: Normally this would use regular expression matches, cached database
[Code].....
However, I need to reference Url and ProductID in the function and I don't know how to pass them as parameters or get their values from the original function.
What is the preferred method of adding the current date/time into an SQL Server table with INSERT Command and executenonquery? I'm expecting something like ...
cmd.Parameters.Add("@theDate", SqlDbType.VarChar, 20)
cmd.Parameters("@theDate").Value = "getdate()"
I am interacting with VB code on a different tier, using a client-side c# program. The VB function signature looks like this:
Public Sub toggleExclusion( _
ByVal mouse As Double, _
ByVal study As Integer, _
[Code]....
I get an error saying no overloaded method of toggleExclusion takes 2 arguments?
I don't know where the extra character 'N' is coming from, there should only be one parameter coming from my SP which is the ID:
cmd1 = oStringConnection.SetCommand(sqlConnectMain, _
cmd1, "TestStoredProc", _
DBConnections.myType.cmdAsProc)
[code]....
When I ran the SQL Profiler, I found this:
exec TestStoredProc @StudentID=N'12345'
Public Function manyarrays(ByVal ParamArray ints() As Integer,ByVal strs() As String) End Function But it is error . How can i fix it ?
View 3 RepliesSuppose I have a function that accepts a string as parameter. But the parameter has a limited number of values (i.e. I've defined the function to work with only say, four exact strings). What I want is that when the user types the name of the function and starts the parentheses, the intellisense will show up giving the values that are defined in the function. Its just like a function that accepts a boolean parameter. The intellisense shows up giving the two values "True" and "False" when using the function.
View 2 Replieswhat exactly is the type of the second argument of CType
CType(testobject, Control)
what exactly is Control? how can Control be used as though it is an expression?i nid to know this because i'm trying to build a function that takes the exact parameters of CType, let's call it CType2public function CType2 (byref object as Object, byval thetype as Type) as Object problem is when i do this: CType2(testobject, Control) they give me "Control is a type and cannot be used as an expression".
I'm program to handle ftp multiple file transfers. What I had in mind was to create an array for each type of file I need to process. There are 8 file types each needs to be transferred to a unique host.
' Each array contains in order: FILENAME|SOURCE PATH|DESTINATION PATH|HOST|USERNAME|PASSWORD
Dim arrA() As String = {"*a*.dat", "/destpath1/", "host1", "id", "pass"}
[Code].....
I'm currently invoking a function that takes ByRef parameters using Control.Invoke (which I notice specifies the Object parameter array to be ByVal) but the array of parameters I give it isn't updated by the function. Is this possible with VB.Net 2003 or must there be some error in my code?
View 5 RepliesIs there a Limit to the parameters that can be passed byVal or byRef to a function or procedure in vb .net ?
[URL]
My program uses parameters from the calling program in this format
parameter1/parameter2/parameter3
parameter2 is a datafile path which may sometimes have a space like :
C:Program Files est company
I did this as a work around
Sub Main(ByVal Args() As String)
dim cArgs as string=""
Dim J As Integer
For J = 0 To Args.Length - 1
cArgs = cArgs & " " & Args(J)
Next
And then used the string split function. Is there a proper way to work with spaces?
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 Repliestake 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
In the documentation of FileInfo.Create Method it says:
'Declaration
Public Function Create As FileStream
'Usage
[code].....
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?