VB 2008 - Return A Variable Using The Function

Jun 17, 2010

I am writing a program with multiple forms (for inputing loan/financial information - so they are set up exactly the same albeit a form number (ie: 1-6)) that feed into a summary page form to display each individuals form's information. When the user closed a financial form, it then feeds the information to a summary page using the code I have below: [Code]. I am new to working with functions, and have not been able to find anything that can show me how to fill multiple textboxes with them (I only know how to return a variable using the function to work a calculation). Any way that I can write a function (or any other call) for this would save me a tremendous amount of coding, and make debugging worlds easier.

View 3 Replies


ADVERTISEMENT

Use Function Return In Global Variable?

Jun 3, 2010

Can't seem to figure out how to use a function return variable in global Dims[code]...

I have also tried adding "FixPath()" under Sub On_load() but got same result. Also the reason I have to have these global is because I have around 30 Subs that refer to "Path" Variable.

View 1 Replies

Return A Variable Based On The Input Of A Function (.NET C# Or VB)

Apr 12, 2012

Say I've got the following variables:

Public Shared x As String = "100"
Public Shared y As String = "text"
Public Shared z As String = "something"

[Code]....

But this doesn't do what I want, naturally. What I want is that my function giveVar returns the value of the variable that holds giveVar. For example I call giveVar("x") I want my function to return "100".

Of course this can be done by a Select Case but thats not what I like to do. Is it even possible to call a value based on a string?

[edit:]

Namespace i18n
public NotInheritable Class Settings
Public Shared LanguageCode As String

[Code]....

I think this works so far, BUT I get the following error on the CallByName(Me, varName, vbGet) at the Me : "me is only valid within an instance method"

View 5 Replies

Debug Calculated Function Returns Without A Return Variable?

Jul 13, 2010

It's often the case that I can write a nice tight little VB.NET function, and when it comes time to do the Return statement, it's really natural to just return the result of a quick calculation or a method call. However, this makes it difficult if I need to step through the debugger to see what is going to be returned from that Function. For example, take this simple method to illustrate the concept[code]...

View 3 Replies

Custom Function Return Type + Input As Variable Datatype?

Dec 1, 2010

I'm wondering whether its possible to have a function's return type and input arguments as a variable.

For example this function:Private Function MyFunction(ByVal argument1 As VariableType) As VariableType

[Code]...

View 6 Replies

Gained By Using The Function Itself To Hold The Return Value Instead Of Declaring A Local Variable?

Oct 28, 2010

What's best practice (in VB.Net):

Function GetSomething() as String
GetSomething = "Here's your string"
End Function
or
Function GetSomething() as String
Dim returnString as String = "Here's your string"
Return returnString
End Function

Obviously, neither of these implementations make any sense, but they're just meant to illustrate my point. Is there anything to be gained by using GetSomething itself to store the return value instead of declaring returnString locally and then returning that (does it avoid having an extra string allocated/instantiated - and if so, are there any performance/memory benefits)?

View 6 Replies

VS 2008 Return Variable From A Webpage?

Apr 7, 2009

excuse my stupidness, i'm fairly new to VB and i've only done a little bit with it before. Basically i am making a little application that i want to run on my machine. Standalone not via a web browser.I have a web page which is generated using php, there is no html code on the page simply a number, e.g. "9995" when you view source.

All i want to do is return this value from the web page (without actually opening the page in a browser) and display it in a text box in VB or store it as a variable that i can use later. point me in the correct direction or right keywords to research, or if you have a simple example that would be even better

View 10 Replies

VS 2008 Use A Function's Return Value?

Jun 5, 2009

If I had this, for example:

vb.net
Public Function Check
Dim FCheck As Boolean

[code].....

View 2 Replies

VS 2008 : Return/save The Value In A Variable - Button?

Jun 25, 2011

When i press the button3, i want the webbrowser change site after how mutch the clock is. Is the clock between 9:00 and 17:30, the webbrowser is gonna change to swedish sites. If the clock is between 17:31 and 21:30, the webbrowser is gonna changes to american sites. But the webbrowser is only choose ONE swedish site and ONE american site. The problem is that the variable b does not save the value it has before.How to i make so the variable b saves the value it has before? b = b + 1 is gonna be first 1. Then if i press the button3 agin, it gonna be 2. and if the value is 3, it gonna be 1 agin.

PHP
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim changesSE(3) As String
Dim changesUS(3) As String

[code]....

View 1 Replies

VS 2008 Having A Function Return Two Values

Aug 19, 2009

I'm having trouble with a function returning two values. Each value contains a string, how can I return these values and have each one of them be stored in one independent variable. [code] I'm trying to return the hashed text with the salt and the generated salt, how can I do this?

View 18 Replies

VS 2008 Return Statement In Function?

Apr 12, 2010

1. I would like to know why a Return statement is needed in the function in the first set of code, but not in the second(even though it still works with the Return statement). The functions are called the same way, so what is the difference?2. Why in the second code, the variable FutureValue is allowed to have the same name as the function? But when, in the first set of code, I try to rename the variable "discountPercent1"(in the function) to the function name "SetDiscountPercent", VB 2008 Epress gives the error message "The name conflicts with an existing symbol with the same name"?

Public Class frmInvoiceTotal
Private Sub btnCalculate_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalculate.Click

[code].....

View 4 Replies

VS 2008 Function Does Not Return A Value On All Code Paths?

May 5, 2009

How can I handle the above warning? Should I just return nothing when an error occurs?

te Function RetrieveAllCustomers() As DataTable
Dim adapter As New OleDbDataAdapter
Try

[code].....

View 8 Replies

VS 2008 Return Results From Function Run In A Thread?

Feb 3, 2010

I am running a query in a thread but I can't figure out how to get the result back to the calling function. I am doing something like this:

Threading.ThreadPool.QueueUserWorkItem(AddressOf RunThread, "some query string")
Private Function RunThread(ByVal stateInfo As Object) As String
Dim myQuery As String = stateInfo.ToString

[Code]....

View 3 Replies

VS 2008 Way Of Declaring A Parameter In Function And Return A Value?

Apr 26, 2010

I have created my own ListViewItem class, and added some custom properties to it of attributes. What I have at the moment is a tooltip which shows all of those custom properties (about 18 of them).What I want to be able to do is if multiple are selected, to show a tooltip, but if a property (say Title) for all of them is "My Title" it will show that, otherwise if they are different, I would like it to show "VARIES"Is there a way of declaring a parameter in my function and return a value? [code]

View 1 Replies

VS 2008 : Function Returning Variable Array?

Jan 31, 2010

I should be able to pass an array of numbers, calculate average, lowest number, highest number, and standard deviation.the function returns an array containing the results. I dim public data

Public dataArray() As Double
Public DataIndex As Integer = 4
Private Function CalculateData(ByRef dtArray() As Double) As Double()

[code]....

I get an "error Number of indices is less than the number of dimensions of the indexed array" stats()If I add a dimension there like stats(Dataindex) I get an error "Value of type '1-dimensional array of Double' cannot be converted to 1-dimensional array of double".

View 2 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

Program Function - Says, "The Type For Variable [variable] Will Not Be Inferred Because It Is Bound To A Field

May 18, 2012

Public Class Form1
Dim x, c, number(0 To 19) As Integer
Dim s As Integer

[CODE]...

The variables in the brackets [example] do not actually have brackets in them in the original code. These are where the issues are. For both variables, it says, "The type for variable [variable] will not be inferred because it is bound to a field in an enclosing scope. Either change the name of [variable], or use the fully qualified name (for example, 'Me.[variable]' or 'MyBase.[variable]')." Now, I'm not entirely sure if this is a stupid question or not, as I'm used to VB '98 because that's what we use in my programming class at High School. let me know why this won't work.

-Note: The intention of this program is to continually loop the generation of numbers for this list until I tell it to stop. Button1 ends the program, Button2 generates the list one time only, Button3 is supposed to loop the generation of the list, and Button4 is supposed to end the loop, but not the program.

View 9 Replies

Write A Variable To A File That Has A Different Type Than The Function Assigned To The Variable

Sep 17, 2011

I have the following code that I am using to parse out a test file. I am getting variable conversion error in Sub Main() when I assign file = Read(). The return value of Read() is a TextFieldParser type. How do I assign the proper variable type to "file" so I can write the output to a text file?

Function Read()
Using MyReader As New FileIO.TextFieldParser("C:UsersColinDesktopParse_Me.txt")
Dim currentRow As String

[Code].....

View 3 Replies

VS 2008 Getting Error "function 'getRemoteMac' Doesn't Return A Value On All Code Paths"

Jun 14, 2010

im trying to get mac adddress from this code but i get eerror on END FUNCTION line it says this "function 'getRemoteMac' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used." what am i missing here?

[Code]...

View 3 Replies

Setting A Variable To Accept The Result Of A Function By Calling The Function With Many Parameters

Feb 17, 2011

I'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.

View 9 Replies

How To Return The Variable Name Itself

Dec 10, 2010

1. How to return the variable name itself? Public Class test Public Shared as String = "111" End Class I want to return AAA but no 111, test. = "111", and test. Tostring = "111"

2. I want to join the space char into the variable, for example A B but no AB, how to do?

View 7 Replies

Asp.net - SQL Select Return Value To Variable

Sep 14, 2009

working with: ASP.net using VB.net connecting to MS SQL Server

What I'm trying to do is take the result of a SQL select query and place that in a string variable so it can be used in things like a textbox or label. code so far that doesn't work...

Imports System.Data.SqlClient
Partial Class dev_Default
Inherits System.Web.UI.Page
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)

[Code].....

View 3 Replies

How To Return Variable From Thread

Mar 10, 2009

This is my simple code that calls a function from a class I created called "clsNetwork". The function simply pings a computer from a computername I pass it and returns the results.

Dim PingStatus As String
PingStatus = clsNetwork.PingComputer(ComputerName)
txtbox.text = PingStatus

View 13 Replies

Making An Object Return Its Own Variable Name?

Dec 10, 2009

I was wondering if there's a way I can make my objects return their own variable name as a string, something like this:

Public Class MyClass
Public ReadOnly Property VariableName() As String
Get

[Code]....

Is this possible? I'm fairly sure it should be possible through the System.Reflection namespace, but I can't figure it out.

View 7 Replies

Return Class Variable On Form?

Jan 27, 2010

I wrote the following two functions in a class to take a gpib reading and also take a measurement from an LCR meter.
HTML
Public Function gpibRead(ByVal Channel As Integer, ByVal buffer As Integer) As String
Dim readingBufferA1 As String
Select Case Channel
Case 1
readingBufferA1 = gpibLCRA1.ReadString(buffer)
Return readingBuff
[Code] .....
When on the main form I call the funtion takeMeasurement(1) how can I get the LCR readings back. If I try and use readingBufferA1 on the mainform it doesn't recognize that as a variable. I know that it is taking the reading and storing the correct numbers because I am monitoring on NI Spy.

View 6 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







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