Get The Reference Of A Public Variable Using The String Name In Another Form?

Feb 25, 2011

I have public variables in a module. I need to get the reference of the variable by using the String name of variable in another formell me how to do this?I need something like the following code:

Dim Var1 As string
Dim sVariableName As String = "Var1"
GetReference(sVariableName).SetValue = "testing"

[code].....

View 2 Replies


ADVERTISEMENT

Public Variable Not Delared In Other Form

Aug 9, 2010

I defined a variable in a form with

Then I want to check that variable in an other Form using[code]....

View 3 Replies

Create A Public Variable To Use On Any Form In The Application?

May 28, 2009

I have a query setup on the start form in my project - it looks for a user level (1 or 2 right now) I want to display/hide items on the form based on whether or not the user's permission (derived from this query) is a 1 or 2.

My question is, can i create a public variable out of this query to use on any form until the application is quit?

The query will be formatted something like this:

Dim
ssSQL As String = "SELECT UserLevel FROM [Employees] WHERE "
ssSQL &=

[Code].....

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

Release Public Shared Variable After Form Close?

Mar 4, 2010

shared variables of particular form in vb.net 2005

View 1 Replies

Declare A Public Variable And A Public Sub In An Aspx Webpage?

Aug 26, 2010

How do declare a public variable .aspx web page that can be used in all the pages within my web application?

View 3 Replies

Combine Text And String To Reference Variable

Oct 4, 2009

I'm trying to combine some text and a string value to reference a variable name.[code]

View 4 Replies

VS 2005 Reference A Member Of A Structure By Using A String Variable

Mar 20, 2009

, I was wondering if it was possible to reference a member of a structure by using a string variable. Here's an example of what i'm talking about:

[Code]....

Now, I know that you would usually reference the value in any of the members by using the following (String1 in this case)

[Code]....

View 4 Replies

Reference A Form From A Variable?

Nov 24, 2009

I am upgrading a very large project from VB6 to VS2008. I have several forms with dozens of combo boxes on each form. I use the same combo box names for each form and want to fill them from a module with different items depending upon the calling form. In VB6, I dimensioned a public variable - FormName as object and called Set FormName = frmMyForm1 on Form Load. In a module, I was able to write the following code:

With FormName
.combobox1.additem("item")
.combobox2.additem("item"
End With

I cannot make this work in VB.Net. When the form loads I call FormName = Me. If I dimension Friend FormName as Object, I get the error message that Public member combobox1 on type MyForm1 not found. If you are attempting to access members on a late-bound object make sure it is declared public". If I dimension Friend FormName as Form, I get an error that says "combobox1 is not a member of System.Windows.Forms.Form".

I have tried both CType and DirectCast to convert the form variable from Object to Form with no success. I also tried creating a public array and storing each form name in it.

View 4 Replies

Forms :: Reference Form Using Variable

Aug 18, 2010

I have an application consisting of 2 forms (Form1 and Form2).There is a text box on each form and they are both named Text1.From a sub routine in a module, I want to alter a text box on one of the forms. The sub determines which form to write to and attempts to refer to the form using a variable.But in the example below, gForm never gets declared when it's nested within the If statement.[code]The actual application is not so simple and I need to use this or a similar approach throughout the application in order to reduce code redundancy.To recap, I want to alter a control on a form by replacing the form name with a variable name. [code]

View 4 Replies

VS 2008 Dynamically Declaring A Constant - Public Const Blah As String = Variable & "something"

Aug 5, 2009

How would I go about dynamically declaring a constant? (It's value is dynamic, not the variable name)

View 5 Replies

Call A Form By String Reference?

May 16, 2012

I am trying to open form using a string reference in loop.

Dim XXX As Integer
Dim slideName As String = Nothing
Dim slideNameX As String = Nothing

[code]....

View 4 Replies

What Is Different Between Global Variable And Public Variable

Jul 15, 2010

What is Different between global variable and public variable?

View 1 Replies

Pass Variable By Reference And Set Object To Reference?

May 26, 2010

I pass this class i created a variable by reference and i want that reference to be assigned to m_Text so that when i change m_Text it changes the TextValue variable i passed. Example:

Dim test2 as String = "ok"
Dim test as New GeneTextBox(test2)

'then some one changes the text in the GeneTextBox and i want it to change the test2 string...

Public Class GeneTextBox
Inherits Windows.Forms.TextBox
Private m_Text As String
Public Sub New(ByRef TextValue As String)

[code]....

View 1 Replies

VS 2008 Public Function Null Reference

Oct 2, 2009

why I am getting a NULL reference error. Form: Public Sub CreateSession() ' This will be the execution function after the date, provider, session type, session number ' and consumers have been entered. Each Consumer will have it's own tabpage and seperate record.

[Code]...

View 31 Replies

.net - Variable 'cl' Is Passed By Reference Before It Has Been Assigned A Value For DataView Variable?

Feb 1, 2012

I have the following code passing a dataView variable to a function and I am getting the following warning:"Variable 'cl' is passed by reference before it has been assigned a value. A null reference exception could result at runtime."

Function Editclass()
Dim cl As DataView
Bindclass (SqlConnection2, cl)

[code].....

View 1 Replies

Non Hard Code Way To Reference Public Documents Folder?

Nov 6, 2011

What used to be C:Documents and SettingsAll UsersApplication Data is now Win7 as C:UsersPublicPublic Documents or similar..This folder is not part of the Environment.SpecialFolders list. Is there another way to expose the above Public folder?I'm hoping you can programatically use that location for non virtualized read/write/alluser files.

View 1 Replies

Passing Parameters By Reference Into Public Shared Methods

Oct 21, 2009

I have a List(Of AddlInfo) with AddlInfo being an object. I'm trying to pass addlInfoList by reference into a function of another class:

[Code]...

This works if I'm not passing the reference into another class, but when I try to do this, I get the following error: Overload resolution failed because no accessible 'Sort' can be called with these arguments:

[Code]...

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

.net - Using A Class Like A Public Variable In Asp.net?

Apr 13, 2009

I'm getting an error in .net when trying to declare a Public class on my code behind page.

Partial Class _Default Inherits System.Web.UI.Page

Public someVariable as integer
Public someClass as className

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load [...]

The error I'm getting is BC30508: 'someClass' cannot expose type 'className' in namespace '<Default>' through class '_Default'.The goal here is accessing the class properties in script blocks on the aspx page like this <%=someClass.classProperty%>

I'm not sure if I'm trying the right methods (I've tried several ways of declaring the public class) or if it can even be done..

View 3 Replies

HOW To Declare A Public Variable

Apr 23, 2012

Later on i have a form where a cost for a class is calculated by timing the duration of a class by the costperhour textbox which is in a different form.

View 3 Replies

How To Reset Public Variable

Oct 28, 2009

I have few public Arrays variables, I need to reset them since I will be using them few times with different values.

View 3 Replies

Public Shared Variable Ref?

Jun 29, 2011

I have an arraylist in a user form (Mainform) that I would like to be able to share among multiple forms and edit the contents. Using the Public Shared method I have been able to view and even edit the arraylist, but it does not seem to be changing it back on the main form. I can give more detail if needed.

View 9 Replies

Using Properties (rather Than A Public Variable)

Jan 19, 2010

Is there any point in using a property (rather than a public variable) if it just says:

[Code]...

View 1 Replies

Convert String Variable Into Form Object?

Jun 12, 2009

I have a string value of form names in my DB so when my condition passes, the variable string will take over the value , then that value will call the form(variable) as string.

[code]...

View 3 Replies

Forms :: Properly Set A Public Variable?

Oct 31, 2010

I want al(InitialStrength.Text) to be set as the variable iST so I'm typing this at the top of the page before all my subs:

Public Class CharacterSheet
Public iST As Integer = Val(InitialStrength.Text)

[code]....

but every time I do that and try to compile without even using the variabe, I get this error: "An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."

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

Pass A Public Variable To A Sql Query?

Nov 4, 2010

I have a public variable that I declared in form1 of an application. I am trying to call that variable in form2 and then pass that variable in a sql query.

If I declare

Public Class Form1

Public payPeriodStartDate, payPeriodEndDate As Date

How then to I declare that variable in form2 and how to I pass it to my sql query

SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO ScratchPad2[code].....

View 13 Replies

Public Variable Goe Out Of Scope In Private Sub?

Aug 23, 2009

I have a public variable which seems to be going out of scope. I am confused as it has been dimensioned as a public variable: Public xlCell as As Microsoft.Office.Interop.Excel.Range

I originally had all my code in the same module in the same project and it was wrapped within a For/Next Loop (Example 1). I decided to clean up my code and make it more modular (Example 2). All the code is still in the same module in the same project.

Upon doing so, my public variable is not recognized in any of the private subs that I have created. I keep getting the following error: Message="Object reference not set to an instance of an object." When I test the variable using ?IsNothing(xlCell) in the Main Sub I get False in the main sub. this tells me te variable is recognized. However as soon as the Call SelectCaseSub() is triggered, I get a True value for ?IsNothing(xlCell). Why is this? Shouldn't this variable be in scope regardless?

[Code]...

View 6 Replies

Reassign Value For Public Long Variable .net?

May 3, 2012

When using the variable tTimeInterval as Long trying to reassign the variable in the timer's sub,

but the tTimeInterval is 0 after enter in the sub,,
Public tTimeInterval As Long Sub Main()'Dim param_obj(2) As Object 'param_obj(0) = "sdaddsa"
'Dim aThread1 As Thread = New Thread(AddressOf SendingMessage4)
'aThread1.Start(param_obj)tTimeInterval = 5000

[Code]...

View 1 Replies







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