Construct A String And Use It To Call A Variable?

Aug 3, 2011

This is probably a dumb question but I have to call one of 30 or so global variables by constructing the variable name to be called from another information. However when i do that it treats it as a string. Any ideas on how to make this work?eg something like this:

Public gsNewYork As String
public sub Getinfo
dim lslocation as string

[code].....

View 1 Replies


ADVERTISEMENT

Call Or Set Variable Value When Its Name Is Stored As String

Jun 6, 2011

My application has a variable VAR_1 that is boolean, this name is also stored in database.

Now I need to set VAR_1 value in my app by reading database and asign x value,

How do I call VAL_1 from a string?, this is:

Dim VAL_1 as boolean

Dim str as string = myTable.Rows(0).item("x") <--- Here's the name "VAL_1"

But I just can't find how to call VAL_1 by converting "VAL_1" to variable

View 10 Replies

Forms :: Call Mdi Form Toolstripmenuitem Name Using The String Variable?

Jul 8, 2009

i need to call mdi form toolstripmenuitem name using the string variable. for ex, mdi form is Form1. toolstripmenuitem is customer master if i do like that "Form1.customer master.Enabled=True" its working

but my issue is i stored customer master in a string variable like mystring="customer master" i need to enabled using the string variable like Form1.mystring.enabled=True

View 11 Replies

String Variable For Use With LINQ To SQL Class Stored Procedure Call Has Weird Message?

Feb 4, 2010

In my project I am using a LINQ to SQL class that contains a stored procedure which includes a string value as an output parameter.So to capture that, I created a string variable as follows in the procedure:Dim spOutput As String? However, when I do this I get the following message "Type 'String' must be a value type or a type argument constrained to 'Structure' in order to be used with 'Nullable' or nullable modifier '?'"

View 2 Replies

Search A String Variable And Place The Match Into Another String Variable In Visual Basic?

Nov 18, 2009

I'm looking for a way to search a string variable for two words and copy the text in between them into another variable. This needs to be done as many times as the match occurs.

View 3 Replies

VS 2008 Use The Value Of One Variable To Call Another Variable Of The Same Name?

Feb 7, 2011

I am trying to use the value of one variable to call another variable of the same name.I have 2 variable one called VAR1 and VAR2.

The variable VAR1 has a value of "VAR2"
The variable VAR2 has a value of "HELP"

I want to be able to get the value VAR2 from the variable VAR1 I have defined the value of VAR2 early in the code and now I want to call that value by using the value of VAR1.The reason I am doing it this way as I have a list of 50 variables that are pulled from one system. Each of these variables have the same name as the columns of a spreadsheet. The total number of Variable stay the same but the total column headers may vary each time. I need to loop through each of the column headers match them with the variable names and add the data to the spreadsheet.

VAR1 = "VAR2"
VAR2 = "HELP"
i =1

[code]....

This is the tricky bit...if the value of the cell(1,i) = "VAR2" How do I get it to display the value of the variable of the same name In this case how will I get it to display "HELP" when I only have from the VAR1 value "VAR2" I know my code will bring back the value as a string but I want it to bring back that string as a variable and display the value of that variable?

View 9 Replies

Call A Class From A Variable?

Jul 17, 2009

How can I call a class from a variable ?

Something like :

Dim strClassName As string = "clsAction"
Dim newclass = strClassName

I know that this code doesn't work, but how can I do it, if possible.

View 4 Replies

Call A Subroutine By Variable Name (In .Net)?

Jun 21, 2010

what I need to do is to call/run/execute a subroutine using a varaible name from a subroutine.

Public Sub Main(ByVal subName as String)
Call subName ' subName may be contain the value AAA or BBB
End Sub

[code]....

View 5 Replies

Call Member Through Variable?

Nov 6, 2010

I have a class with something like [code]...

By doing this, i want the label to display value of cube.m10

I've tried other things like quotation marks or brackets but doesn't seem to work.

Is it possible to do without being too complicated?

View 3 Replies

Use A Variable To Call A Text Box?

Jul 27, 2011

Im new to VB and have written an application which copies data around a network. Im trying to simplify the code that does the copying so i can get it to run as a module.[code]...

View 5 Replies

Using A Variable To Call A Function?

Aug 27, 2010

I have searched, but am not exactly sure what to call this process, so it's difficult to know what to search for. I have a set of functions that are almost Identical, so I want to call them, for example, function1(), function2(), function3(), etc. I want to be able to define and call them with a bit of code that says something like.

[Code]...

View 3 Replies

VS 2008 Call .exe From VBA Using A Variable

Apr 7, 2010

I have created a project using VB.Net(VS2008) and created the exe file. I have another project in VBA (Excel 2003). The project basically IC-Testing based. So according to the device type the Excel workbook name varies. For example I have AAAA.xls, BBBB.xls, CCCC.xls. When I open AAAA.xls, I want to call the .exe (which is developed in VB.Net) with the variable "AAAA". i.e when the exe program runs, it knows which Excel is opened or from which Excel the .exe is called. now I am using Shell retval=Shell("d:Monitor.exe",1). Using this the exe is called and running fine. But the Monitor.exe doesn't know which Excel called it, whether it is AAAA.xls, BBBB.xls or CCCC.xls.

View 1 Replies

Call A Variable With A Variable?

Aug 27, 2010

I'm attempting to set a variable from a variable i've searched high and low and looked in many books but still to no avail. I guess i'm using the wrong keyword.I have many public variables like this:

View 4 Replies

VS 2010 Merging An Integer Variable With A String Variable?

Jun 2, 2011

Say I have something like this

Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")

[code].....

View 7 Replies

Call A Variable Without Addressing It Directly?

Jul 10, 2011

So I am having an issue where I want to call a variable without addressing it directly and I get an error for it:

Conversion from string "player1BuzzLock" to type 'Boolean' is not valid.

This is technically correct but why would it fail?

Dim player1BuzzLock As Boolean = False
Dim PlayerNum as Integer = 1
'...
Dim playerBuzzLock As Boolean = CType("player" & PlayerNum.ToString & "BuzzLock", Boolean)

View 13 Replies

Call Event (method) From Variable?

Mar 9, 2010

If I have a string that contains the name of a control is there a way to call that control's click event?

Dim a as string = "MyButton1"

Now I want to call MyButton1.Click Method or MyButton_Click Event using the contents of a.

View 7 Replies

Function Variable To Be Separate For Each Call?

Nov 14, 2010

Private Function TestFunction (byval VariableA as SomeClass)
Static VariableB as integer
VariableB = variableA.position

[code].....

View 3 Replies

How To Call Variable In Public Class

Aug 22, 2011

I have this public class
Public Class commonSettings
Dim etcString As String = "some string"
End Class
How can I call etc String and use it entirely on my code?

View 3 Replies

VS 2005 Call A Subroutine Via A Variable

May 6, 2009

I'm looking to call a subroutine via a variable. For example:[code]Is that possible?

View 3 Replies

[2008] Call Method Through Variable?

Mar 12, 2009

I using VB.NET (VS 2008). I want to know if I can call a sub whereby the name of sub is in a varialbe.

For example :

Private Sub Hello()
Msgbox "Hello"
End Sub

[code]....

I know it does not work that way but how can I call a function or sub using a variable and not directly.

View 10 Replies

Forms :: Call A Function Whos Name Is In A Variable?

Apr 11, 2011

i would like to call a funtion whos name is in a vairable.

Dim Car_service As String
Private Sub ComboBox_Spray_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox_Spray.SelectedIndexChanged
Car_service = ("Spray_" & Me.ComboBox_Spray.Text)
end sub

Call spray_Standard 'this is what i need to change standard is what comes from the combobox 'but i would like to call the funtion depending on what the combobox.text was eg,' if combobox.text was Parkingsensors i would like to call the function call spray_parkingSensors

Private Sub Spray_Standard()
Price_Subtotal = 0
Price_Subtotal = (Damagecount * 65)
Car_Price_Subtotal.Value = Price_Subtotal
End Sub

View 7 Replies

Should A Local Variable Call Dispose Method And Set To Nothing?

Oct 14, 2009

I have 2 question, hope somebody give me an explanation: 1. Should a local variable call dispose method and set to nothing? 2. If some method have an arguments which it is a ByVal argument, it means a method create a new object? But If it is a ByRef argument, it means a method don't create a new object?

View 4 Replies

Visual Basic .net - Call Procedure From A Variable Name?

Jan 19, 2010

Is there a way to call a procedure in Visual Basic (.net) with a variable name? For example, the variable strColour can be one of 10 pre-defined values, green blue black white red pink orange yellow indigo purple. How to handle each one is in it's own Sub Routine, colgreen, colblue, colblack and so on.

I can use a bunch of if..then..else and select case, but what I'd like to have is something like VBA Excel's Run "col" & strColour

View 5 Replies

Call An Object Based On A Variable In Visual Studio?

Apr 24, 2012

So I'm trying to write a MasterMind game, but I have a problem I have 40 pictureboxes set up in 10 different rows, and I want to have one code handle all 10 rows, rather than copying and pasting the code and changing the names of the pictureboxes. I've been trying to use a variable to achieve this, but if it's possible, then I don't know the correct way to do it.This is what I have right now:

[Code]...

View 1 Replies

Office Automation :: ByREF Variable Not Updating After Call?

May 31, 2011

I have a subroutine that passes several variables to the called subroutine.I want one of the variables to be updated by the called subroutine and then check for the change in the calling subroutine. My code works fine except that the variable I am checking

calling Sub routine
Code:
Public Sub ProjectName_Exit(Cancel As Integer)

[code].....

View 4 Replies

Combining A String And String Variable Into One Variable

Apr 4, 2009

I am trying to insert a string variable inside of two strings, and make a combined string. Public Sub Page_Load() Dim Id As String Id = Trim (Request.QueryString("Id")) End Sub Dim mp3text as string url... & Id & ".mp3" My goal is to make the mp3text variable have a string that is: url...(If Id is 7) It is for some reason not connecting up correctly. I checked what string it is outputting and this is what it is giving: url...It is missing the Id content.

View 12 Replies

Use CType To Change An Object Variable "obj" To Custom Class That Reference Using A String Variable Like Obj.GetType.Name?

Feb 9, 2011

The code below works for the class that I hard coded "XCCustomers" in my RetrieveIDandName method where I use CType. However, I would like to be able to pass in various classes and property names to get the integer and string LIST returned. For example, in my code below, I would like to also pass in "XCEmployees" to my RetrieveIDandName method. I feel so close... I was hoping someone knew how to use CType where I can pass in the class name as a string variable.

Note, all the other examples I have seen and tried fail because we are using Option Strict On which disallows late binding. That is why I need to use CType.I also studied the "Activator.CreateInstance" code examples to try to get the class reference instance by string name but I was unable to get CType to work with that.When I use obj.GetType.Name or obj.GetType.FullName in place of the "XCCustomers" in CType(obj, XCCustomers)(i)I get the error "Type 'obj.GetType.Name' is not defined" or "Type 'obj.GetType.FullName' is not defined"

'+++++++++++++++++++++++++++++++
Imports DataLaasXC.Business
Imports DataLaasXC.Utilities

[code]....

View 2 Replies

Construct A Data Array?

Oct 27, 2009

I need to construct a data array and I am not sure if I can do what I need to do given the data. I probably should opt to store in a new class but that's too advanced for now

the data describes a series of points. each point has its index in a list a boolean, binary value and a list of integers of its neighbour points. so i thought it would be three columns and the third column would store a list. can you do this?

I presume i could get rid of the column dedicated to storing the integers..

View 13 Replies

Construct XML From A Custom Object?

Dec 20, 2009

I need to construct an XML transaction of the following format[code]...

I was thinking of creating a "GetXml" function on my object that returns the XML representation of the values in the object instance.I could do all the string concatenation myself, but surely there is a cleaner way.

View 4 Replies

Creating NEW Construct In A Class?

Dec 31, 2009

I have an application in VB.Net and now I find out an API is not compatible and requires VB6. I am trying to convert it back to VB6 and have an issue in a Class Module. In VB.Net, I have:

[Code]...

View 7 Replies







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