Asp.net - Returning Multiple Values From A Function In An Parcial Class In VB?
Sep 6, 2011
show me how to return multiple values from a function? I have my function in a seperate file within App_Code and here it is:Public Function GetQuoteStatus(ByVal QuoteID As String) As String
Dim quoteStatus As String
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Try
con.ConnectionString = ConfigurationManager.AppSettings("quotingSystemConnectionString")
con.Open()
[Code]...
However this is all good and well for one returned value but what If I wanted to return multiple values.How do I access them?
View 3 Replies
ADVERTISEMENT
Mar 17, 2009
I am working on a project I would like to use a function in a class I created to return multiple values in order to populate a listbox. I wanted to use a do until loop to achieve this. I will just post a simplified example of what I am doing :
Public Function Listboxfiller
Dim astring As String = "This is a string"
Dim Counter as integer = 0
Do until Counter = 5
return astring
Counter += 1
Loop
Then on the form I would do something like :
lstListbox.Items.Add(Myclass.Listboxfiller)
What happens right now is that the listbox only gets the first value, when I ran through in debug mode I found the loop only runs once, even though it should go multiple times.
View 4 Replies
Apr 1, 2010
I have an active directory search function:
Function GetAdInfo(ByVal ADDN As String, ByVal ADCommonName As String, ByVal ADGivenName As String, ByVal ADStaffNum As String, ByVal ADEmail As String, ByVal ADDescription As String, ByVal ADTelephone As String, ByVal ADOffice As String, ByVal ADEmployeeID As String) As
[code].....
View 1 Replies
Apr 20, 2010
Is it possible to return more than one value from a function? Like two integers, or an integer and a boolean, or any other data type combination. I understand I could use a sub and set these values in a variable but I was wondering if I could avoid declaring more variables by using a function.
View 28 Replies
Oct 15, 2010
i have this class that i'm calling from a telerik report. when debugging asp.net application the report shows the right results but when i deploy to IIS it just return the first row and not the SUM of the salary variable.
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
[code]....
View 2 Replies
Jul 31, 2009
I'm making this game where there is an enemy that goes to the center of the form and grabs an object and brings it back to the side. I made a new class called enemy that makes the enemy. in the class there is a sub called start which the enemy goes to the center and brings the object back. when the enemy comes back with the object i want the integer lives to subtract 1 from it. so i put the
If Not Rect.IntersectsWith(Form1.ClientRectangle) Then
Form1.Lives -= 1
End If
where Rect is the enemy's bounds. when ever rect is not intersecting with the forms bounds (which means when its off screen) lives should subtract 1, but it doesnt.
View 5 Replies
Jun 18, 2009
Ok simply my code doesnt want to output the correct number. I'm working on the project euler probems to expand my knowledge in VB.net and the current question I am working on is asking to work with triangle numbers. while researching I found that a triangle number can be calculated by using the formula:
[Code]....
View 5 Replies
Oct 15, 2010
look at this class and say why it's just returning just the first row in the second query, the issue is that the Salary is showing the right value when debugging, but when deployed to IIS it's just returning the 1st row
Imports System
Imports System.Collections
Imports System.ComponentModel
[Code].....
View 1 Replies
Jan 14, 2009
I am struggling here with introducing web services into a site I am currently working on. The background is as follows.
- I have a page switchboard.vb which will recieves incoming xml requests.
- I parse these xml requests extracting its values, then setting them equal to the relevant global variables in switchboard.vb.
- One of these variables will determine a 'requestType'. Based on this requestType I want the page to call particular web services that I will add.
- These web services will then validate the user calling has permissions to access and execute it.
- The switchboard.vb page will then generate an xml respose which will post to the client.
Here is a summary of the process
getXML()
parseXML()
determineRequestType()
executeRequest()
rebuildXML()
postXML()
The ways I can see to do this are:
1. Pass the variables into the required Function allowing it to pass back a pre formatted xml string.
Pro: Simple
Con: It is not really using the web service as it should be.
2. Pass the variables into the required Function as 'ByRef' values hense changing the original value on switchboard.vb
Pro: allows me to format the outgoing xml on switchboard.vb and gives me more functionality with more individual variables as opposed to one string being passed back.
Con: Is this taking advantage of a web service? When I tried this the web service form didnt give options to input test data. Possibly because I am using ByRef?
View 10 Replies
Mar 30, 2011
Is it possible to make a function that returns both a datatable AND a list(of custom class) at the same?In my GUI layer, the main form (the application is MDI) calls this function and it has to fill the datagrid on one of its child forms and it also has to fill lot of other child forms with various information that is calculated from my custom class properties.Both the datatable and the class properties are created from the same external database and that's why I don't want to have two separate functions.
View 3 Replies
Mar 15, 2011
I have created a function that takes a Car Registation as its argument and I want it to return 3 values (Make, Model, Price and of course True).The code itself works fine (it returning each Individual value but can't find a way to get ALL of them from 1 function) However I need to actually return all 3 values, and I cannot see how to do this with a simple function.
View 8 Replies
Dec 12, 2011
My brain may just be fried since it's the end of the semester, but my teacher kicked this back to fix and resubmit...she said that I am "returning the name of your function rather than your variable name".
Here is my code for all 3 forms.
code:
These are forms to calculate the cost of getting a cell phone package.
View 6 Replies
Sep 25, 2009
I suspect I am being very silly here but I have the following setup
Class MustInherit myBaseClass
'some stuff
End Class
Class myInheritedClassA
[code]....
Running this results in the following error
Unhandled Exception: System.InvalidOperationException:
There was an error generating the XML document. --->
System.InvalidOperationException:
[code]....
is there any way of 'Widening' the inherited class to the base class so this would work?
EDIT:regarding XmlInclude(typeof inheritedClass), currently this method could potentially return a number of types of inherited class (i.e myInheritedClassA and myInheritedClassB) is it case of simply having to add each of the inheritedTypes in this tag?
View 2 Replies
Dec 14, 2009
returning a function value? I have a simple function that returns an integer. This function works fine when executed in SQL Developer but, when called from my apps, it always returns 2 regardless of anything. I have checked it over and over again, I cant seems to find where I am going wrong.
[Code]...
View 6 Replies
Apr 20, 2009
what changes I need to make to the code so that when no value for intPosition is found the textbox txtRoomNumber remains blank? At the moment a value is being entered into the textbox when no value for intPosition is found.
Code:
Private Sub btnFindRoom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFindRoom.Click
Dim strRoomType As String
Dim intRoomNumber As Integer
[code].....
View 2 Replies
Feb 15, 2011
Just come across the following snippet:
Public Function Checked() As Boolean
Return applyChange 'this is a string!
End Function
Whats going on here? How can a function with return type Boolean actually return a string? I'm assuming theres some implicit conversion going on here, which I'd rather not have.
View 1 Replies
Nov 28, 2011
I am hopeing someone can help me here with a recursive function I have that is not returning either true or false as I would have espected it to. The function loops through a Active Directory group for its members and then calls itself if it encounters any groups within the membership in order to gets its members as well. I am trying to return either true or false based on if any errors were encountered but not haveing any luck at all. It appears to just hang and never return back to the primary calling sub that starts the recursive function. Below is my code I am using:
[Code]...
View 1 Replies
Feb 8, 2012
If an object is created inside a function and the function returns that type of oject how is the memory handled.
Example:
Public Function GetEmployee(employeeid as integer) as employee
Dim oEmployee as new employee
oEmployee.FirstName="Bob"
[code]....
Does the variable that receive the object still a pointer to the memory location that was used inside the function?What about when you do a oEmployee2=oEmployee.Is oEmployee2 just a pointer? And any changes to oEmployee will now affect the other. Just trying to understand it from a memory perspective and how that scope works?
View 2 Replies
Dec 22, 2011
Function returning different datatype
View 4 Replies
Oct 26, 2011
I have stored procedure which I will execute its result and pass it into a Dataset and return it but at the same time I have a Output parameter in my stored procedure which I also want to return, how can I return both the dataset and the integer output value with my function, or is there a more 'appropriate way' to handle such situation?[code]
View 5 Replies
Apr 14, 2009
I need to return an array but the array size will change from one call of the function to another so I need away to storing the returned array. The function is as below, and as you can see the returned array will be of different sizes:
[Code]...
View 4 Replies
Jan 15, 2010
Im overiding getRolesForUser() I have 2 columns i return from the query IAdapter.GetRolesByUserName(userName) returns two columns (roleID, formID) How can I return them and access the two columns data? 2 dimensional array?
[Code]....
View 6 Replies
Apr 3, 2009
is it possible for a VB.net function with a return type of integer to return null ?
View 3 Replies
Oct 3, 2009
Function test(ByVal res As Integer) As Integer
res = 2
Return res
[code].....
View 9 Replies
Aug 23, 2010
I'm attempting to create a function that will get the User Accounts from the registry. I then need to loop through those users and commit specific actions on each one.Here's my function:
VB .NET
ublic Function UserAccounts() As String
Dim userskey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftWindows
[code].....
View 1 Replies
Dec 2, 2010
VB.NET Code:
Module Module1
Sub Main()
Dim x, y As Single
x = 0 + (512 / 2 - 407) / 256 * 192 * -1
[code].....
returns 0: 0
View 2 Replies
Dec 1, 2009
i have this code:
...
Dim Labels() As String
Dim Count As Integer
Count = 0
[code].....
View 3 Replies
Nov 8, 2011
I've got this MustInherit class called ViewerElement, from which derive classes like ViewerLine, ViewerImage, etc.Then, in the main program I have a collection of different elements (Images, Lines, etc.). What I want to do is something like the following:
[Code]...
I'm getting desperate to implement this Clone method without getting errors. How should this be de done?
View 1 Replies
Jul 12, 2010
How could I call a module or something else to return data to me after its ran. I don't want to make my form1 code all messy.
Public Function Test() As String
Return "Tes34t"
End Function
[code]....
View 2 Replies
Jun 11, 2011
i being ordered to change my function skill to returning value by using struct but not using pointer. may i know what is the pro and con between this 2?
View 1 Replies