Access Private Class Variable Names?

Jan 9, 2009

Trying to understand the best way to do this and I'm can't get it figured. Here's basically what I have:

Public Class CardParsingClass
Private iAcctIDStart as integer
Private iAcctIDLength as integer

[code]....

I've only included 2 of the class level fields here but there are actually 30, so that's why I was hoping to be able to send the name of the field to set and the value to set it at in the SetValue function. So in some other routine in the program I'd like to be able to issue the following call:

SetValue("iAcctIDStart", "3")

But then when I get into the SetValue routine, I'm not sure how to proceed. I thought about a case statement that would basically be this:

select Case strFieldToSet
case "iAcctIDStart"
iAcctIDStart = cint(strValue)

[code]....

View 5 Replies


ADVERTISEMENT

Private Read/Write Access And Public Readonly Access For Variable In Class?

Jan 12, 2012

Is it possible to set a variable in my custom class for Private Read/Write access and Public Readonly access without creating Properties with Get and Set? In other words, from within my class I want full access and from my form I only want read access. Right now I declare my variable as either Private or Public to control Public read/write access. I tried googling my question a bit but I'm not sure what the correct terms even ar

View 5 Replies

Variable Class Names - Rename My Class Human To Man

Dec 18, 2009

What i'm trying to do:

I've got a library which includes a class:

Class Human
End Class
and another class which refers to the human class

Class ASD
Private somevar as new Human
End Class

Ok now i've got a problem, i wish to rename my class Human, to Man. i've got to change Human to Man 2 times, which is OK but the problem is that in the real case, its not just 2 times, its like 500 times or more.

Well its something like a PHP on Javascript.

the following shows the solution of what i'm trying to do, but its in another language PHP/Javascript:

note: in php $ sign declares a variable, echo writes the variable out

CODE:

Is there anyway to do that with VB?

View 6 Replies

C# - Using The Value From The Private Variable Or From The Actual Property In Class Functions?

Dec 30, 2009

When referencing class properties from a function within the class do you use the value from the actual property or the private variable value?

public class
private m_Foo as double
public property Foo() as double

[Code].....

View 7 Replies

How To Access Variable Located In Private Sub On Same Form

Jul 25, 2009

How to access a variable that is located in a private sub and then display that variable in another private sub located on the same form.

My actual code is:
Public Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim strFileName As String
strFileName = OpenFD.FileName
OpenFD.InitialDirectory = _
[Code] .....

Obviously, the sub in blue has nothing in it currently and so this is the one I would like to access the variable in. The variable I want to use again is 'FILE_NAME'.

View 27 Replies

Access Private Constants In Class Attributes?

Sep 27, 2011

I have an API that I created and currently utilize successfully in C#. I am trying to create an example of interacting with the API in VB.NET (so that the QA without C# experience can still utilize it for creating automated tests).

In C# I do the following

[TestingForm(FormName= "Land Lines", CaseType= _caseType
, Application= ApplicationNameCodes.WinRDECode, HasActions= true)]
public class LandLines : RDEMainForm

[Code]....

This gives me a compile time error because it claims that FORM_NAME and CASE_TYPE is not defined, even though the class has it defined inside.

How can I use the defined constants inside the class in the class attributes?

View 1 Replies

.net - Populating A List Box With Variable Names From LINQ Generated Class?

Nov 17, 2009

I'm quite new to Visual Basic - using Visual Studio 2008 and can't seem to find a way to do the following:

I have a few tables in a SQL Server database and have used LINQ to SQL to create classes of those tables.

Here's a cut down example of what I'd like:listbox1 filled with table names - APS, SMPS, WCPC, CFLAPS
Then from the SelectedIndexChanged event, listbox2 should populate column headers of the selected table.

I have no issues getting data from the database, and can access all of these headers through the anonymous type objects created from a LINQ query (eg APS.ID, APS.count etc), but populating a listbox with these variable names rather than the data inside them seems rather elusive.

This is probably a cross platform coding question rather than VB specific, so if you have a solution in C# or whatever I'd be happy if you could let me know.

View 2 Replies

Reflection - How To Get Variable Names Types / Values In Current Class

Feb 1, 2011

I am working on a project where my class has to execute VB code provided by the user, to make it simple I am trying to recreate my own eval function, I am using the following code I found on the web to do this task.

Imports Microsoft.VisualBasic
Imports System
Imports System.Text
Imports System.CodeDom.Compiler
Imports System.Reflection
[Code] .....

The problem with code is that it can't access any variables or there values, so I have decided to get the variable names, there values types and there types dynamically and recreate them in the class that is being created dynamically. Any way to get the variable names there types and values in the current class or method, so that I can recreate them, and execute the user passed code, the user knows what variables are in the current class or method and there datatypes but he don't know there values as they may have changed, so he can't initialize them. Is there a way to do this, this code will be called in an asp.net page on page_load event, the code passed by the user is stored in the variable vbCode that is passed as a parameter.

View 2 Replies

VS 2008 Sharing Variables - Private Sub Could Use The Variable Created On Private Sub

Jul 23, 2010

if for example i have two private sub I declared a local variable on private sub a... is there a way that private sub b could use the variable created on private sub a? Im asking because im in a problem in my app were using global variable is not an option to make the long story short

View 5 Replies

C# - Decompiling .Net Assembly Produces Code With Invalid Member Variable Names; Names Starting With $STATIC$?

Sep 5, 2011

I am doing work for a client who has lost the source code for one of their VB.Net WinForms applications. The assembly they have is not obfuscated at all. I am trying to recover as much of the source as I can as C# source and have tried several tools for decompiling assemblies, including Reflector, ILSpy and JustDecompile (all the latest versions), but they all produce code with a huge number of errors in them. Because of the large number of errors in the generated code, I am going to ask about the specific errors (in different questions), get more directed answers and in this way try shed some light on why all the tools are having difficulty decompiling this assembly. This question pertains to the fact that the code generated by all these tools always have a large number of invalid member variables (fields) such as the following:

private short $STATIC$Report_Print$20211C1280B1$nHeight;
private ArrayList $STATIC$Report_Print$20211C1280B1$oColumnLefts;
private StaticLocalInitFlag $STATIC$Report_Print$20211C1280B1$oColumnLefts$Init;

why the generated code has these invalid member variables?

View 3 Replies

Access A Variable From One Class And Use In Another?

Mar 4, 2012

I want to do this: [URL] but in VB. I believe that is for C# I have 2 classes.

[Code]....

I know I've been asking too many questions lately and I do apologise for that. I am trying to learn the basics

View 12 Replies

Access The Variable From Another Class

Dec 1, 2011

how to access the variable from another [Code] I need to call the variable invoiceno in the class xmlserializer using ord1 and assign the value which the user enters during the runtime.

View 6 Replies

Don't Want Any Access To Superclasses Class Variable

Sep 10, 2009

i have an abstract super class and a sublcass.I don't want any access to the superclasses class variable.Access should only be through the subclass method [code] ' now i just want the GetFoo method exposed however all i get is ' direct access to the Foo string.' I made it Friend so that only the derived class SubClass can see it ' but my main program can see it as well//How can i set this up so that the only call availabe would be
x.GetFoo()What have i got wrong ?

View 6 Replies

How To Access Class Variable Via Array

Mar 23, 2009

If I have the following class and declaration:

Public Class objLocation
Public SysLocationId As String
Public NameFull As String
Public LatRaw As String
Public LongRaw As String
Public Active As Integer
End Class
dim lLocation as new objLocation

I can access each variable thus lLocation.SysLocationId, etc. Is there an alternate way, so I can access each variable by index, so something like lLocation(0), lLocation(1), etc., which gives me the flexibility to compare to classes of the same type via a for next loop, or against other sources, like a datatable.

View 6 Replies

Declare A Variable For Instance Variable With Dim Not Private?

Feb 6, 2011

why don't we declare a variable for instance variable with dim not private?

View 3 Replies

Access A Class Variable Inside Shared Method (JSON)

Jun 20, 2012

Inside my .aspx I have some JSON code that looks like this:

[Code]....

Basically what I'm doing is pulling text from two labels on one page, and sending them to another page by calling the "doIt" function which looks like this:

[Code]....

Just so I'm clear, the "doIt" function and the JSON call are on two separate web forms. My problem is that with the "doIt" function being Shared, I can't access any global variables of the class. And if I remove the Shared, my JSON doesn't execute.

View 1 Replies

Access Global Variable Inside Class Contained Within Module?

Nov 25, 2009

I've got a console app with a sub main then i have a seperate class inside the module..i can't seem to update the public global variable from inside the class as i can't declare the variable as shared...

View 6 Replies

Can't Make Difference Between Public Class And Private Class And Friend And Protected Friend Class

May 15, 2009

I can't make difference between public class and private class and friend and protected friend class.

View 1 Replies

Private And Public Class At Class Library

Mar 12, 2011

I'm posting this there is a relationship with my previous post [URL]

I have two projects, namely:

1. Project1 (Windows Application)

2. Project2 (Class Library)

in Project2 there are several classes:

* frmLogin.vb
* frmCustomer.vb
* clsGlobals.vb

in my case, I want to frmLogin.vb and frmCustomer.vb not called in Project1 and I can only call is clsGlobals.vb

View 8 Replies

Loop - .net For Each Private Variable?

May 10, 2012

I'm working in VB.net and I want to create a generic ToString. is there a way to do a "For Each" in "Me".

[Code]...

View 1 Replies

Use A Private Class And It's Members From Another Class?

May 18, 2009

I usually use which is free, works a little too well, it's obfuscating the code that passes between my scripting class and the other classes, so after obfuscating the app, the scripting functions no longer work.However I found another obfuscator called Skater lite which is a free edition, it will only obfuscate private classes and members, so what I would like to do if possible is make most of my classes private and their members (except for the scripting class, which should allow it to work properly after being obfuscated), and somehow still use them globally, declaring an instance of the class doesn't seem to work, I'm not even sure it's possible and I know little about the scope of private classes, so anyone got any ideas or workarounds?

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

Declaring Private Variable - Automate Properties?

Sep 28, 2009

I come from C# (use VS 2005, .NET 2) and I know that when I declare a private variable I can "extract" from it the corresponding "property". In VB.NET I've declared a lot of properties (in the diagram class designer). Now am I forced manually adding the corresponding private fields?

View 4 Replies

Private Variable Instantiation: When Defined Or Within Constructor?

Jun 24, 2010

I don't know if this has been asked before, but we're having a discussion about it today at my job. Should private variables (that are shared/static) be instantiated when they are dimensioned/defined, or is it a better practice to do this inside of a constructor?

Public Class IpCam
Private Const HOST As String = "http://test.com/url/example"
Private Shared _Example As New OurClass(HOST)which one to use?

[code].....

View 4 Replies

Name An Event Handler Of A Private Variable In Following FxCop Rules?

Apr 22, 2010

On one side, in Vb.Net when you add an event handler to an object the created method is named: <NameOfTheObject>_<NameOfTheMethod>.As I like to have consistent syntax I always follow this rule when creating event handlers by hand.On the other side when I create private variables I prefix them with m_ as this is a common thing used by the community, in C# people use to put _ at the beginning of a variable but this is no CLS compliant.

View 1 Replies

Difference Between Private Sub / Function And Class

Oct 30, 2010

What is the difference between Private Sub /private Function / Private Class and to use them?

View 4 Replies

Make Compiler Flag Unitialized Form's Private Variable As Error?

Jun 29, 2010

I can make the compiler give me an error (Use of variable prior to assignment) with:

private sub Test()
Dim ord As Order
Dim ord2 As Order

[code].....

View 2 Replies

.net - Reflection Retrieve Private Methods Of A Class?

Sep 13, 2010

I want to retrieve private (implementation and other) methods of a class which implements an interface and also is derived from (inherits) a base class.How can I achieve this using reflection?This is wat m tryin to do. I need to view these private methods and their contents, I don't want to invoke them.

Dim assembly As System.Reflection.Assembly
Dim assemblyName As String assemblyName = System.IO.Path.GetFullPath("xyz.dll")
assembly = System.Reflection.Assembly.LoadFile(assemblyName)
assembly.GetType("myClass").Getmethods(Bindings.NonPublic)
assembly.GetType("myClass").GetMethods(BindingFlags.NonPublic) isn't working

View 2 Replies

Class Private/Public Naming Conventions?

Mar 25, 2011

I'm relatively new to .NET and am wondering how people handle naming their private variables and the public properties that access them. Like if you want to be able to just read it, but not write to it.

[Code]...

So far I've taken to putting a 'l' (for local) in front of the all the private variables so as to be able to use the full name for the property. Is there a better way around this, or do you just always have to have different names for private variable/public properties? If so, what sort of conventions do people use?

Its not a huge deal, its just a minor annoyance and I was wondering if I was missing something.

View 4 Replies

Class, Method, Namespace, Private Vs Public?

Feb 16, 2012

what websites, books or courses you guys suggest to use so I learn the fundamentals of programming. What is a class, method, namespace, private vs public. That leads me into .Net programming. A lot of intro to programming use java or C++ as the platform but I want to find one with VB.net or maybe C# if.

View 6 Replies







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