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


ADVERTISEMENT

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

Get The Name Of Parent Method/class/file Name Inside Other Method Call?

Feb 16, 2010

I will try to explain what I need.Let's say that I have a class like this:

Public Class Example1 Public Sub ToBeCalled()

[Code]...

View 5 Replies

Create A "shared" Variable That Is Shared With All Instances Of A Class?

Jan 14, 2011

I seem to be drawing a blank. I'd like to create a "shared" variable that is shared with all instances of a class but not classes that inherit from it. For example.Class A: Shared list As New List(Of String): list.Add("A")

Class B Inherits A: list.Add("B")Class C Inherits B: list.Add("C")The end result I'd like is that any instance of A has just A in the list. Any instance of B has A and B in the list. Any instance of C has A, B, and C in the list. I can accomplish it by creating Instance variables, but I have to construct the list for each instance of a class. I'd like to construct it once for a specific point in the Hierarchy and then share it accross other instances of that class.

View 12 Replies

Local Variables In Shared Method Work Like Static Variable In C?

Aug 23, 2011

Will the list in this shared method keep its state throughout the life of the method? Or will a new list be created every time this method is called?

[Code]...

View 3 Replies

Call A Shared Method In A Loaded Dll Using Class Name?

May 8, 2012

[code]...

Dim ass as Assembly = Assembly.LoadFile("sample.dll")

Now, I want to call the shared method using the class name.

View 1 Replies

Override A Public Shared Method In Derived Class?

Oct 8, 2010

Can we override a Public Shared method in derived class? If not why?

View 2 Replies

Inside The Service Class, Declare A Class Variable Named Started?

May 8, 2012

Create a class named Service. Inside the Service class, declare a class variable named Started. The datatype of this variable is Boolean.Public Class Service Dim started as Boolean End Class Create a class named Server. Inside the Server class, declare a dynamic array that can contain elements of the type Service.(Note: For convenience, both the array and the variable Started can be accessible from a client program that creates an instance of Server and Service respectively)

Create a constructor for the Service class. When the constructor is executed, it will set the value of the class variable Started to True. Create two new classes: WebServer and DatabaseEngine. Both of these classes inherit from the class Service. Inside the Service class, declare a Sub procedure (method) named Terminate. This method should display the following text Service stopping in a message box when executed.This method can be overridden in classes that inherit from Service class.

Inside both the WebServer and DatabaseEngine class, override the method Terminate inherited from their base class Service. Both methods should first call the base class Terminate method. The messages Web server stopping and Database engine stopping should also be displayed in a message box when the Terminate method for the WebServer and DatabaseEngine are called respectively. These messages should only be displayed if the Started variable inherited from their base class is not equal to False.

Inside the Server class, declare a method named Shutdown. This method does not return any value. When executed, it will call the Terminate method for each of the Service instances (if any) in the arrServices
array. You should call the Terminate method within a For Each loop that loops through the elements of the arrServices array.

In the Sub Main method, create an instance of the class Server. Set the size of the arrServices array in
your Server instance to contain 2 elements. Create first a WebServer instance and then a DatabaseEngine
instance into this array. Call the Shutdown method from your Server instance.

View 7 Replies

Accessing A Public Shared Variable From A Different Class?

Jan 10, 2012

I currently have two forms, and I need to share the value of a variable in one of them.

I declared the variable to be 'Public Shared', and assigned a value to it. However,

when I inspect the value it appears as 'Nothing'. Here is the snippet:

Public Class A
Public Shared sVar As String = Nothing
Private Sub A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[Code]....

View 4 Replies

VS 2008 Shared Data Access Method?

Jul 31, 2010

use of the shared function, which returns a reference to a datatable to the calling code. While there a probably many debates as to the preferred use of ADO.NET objects, my question is about the Shared Method aspect. Note that the dataTable is declared within the Shared Function, so it seems to me you get a new one every time, yes?

Public Shared Function MyData() As DataTable
Dim ReturnData As New DataTable
'A silly example of retreiving some data into a datatable:
Using cn As New SqlClient.SqlConnection("SomeCOnnectionString")

[code]....

View 4 Replies

Variable Inside A Method Is Compiler Generated

Aug 24, 2010

Is there any way to know that a variable inside a method is Compiler generated.when decompiling a .net dll or exe the generated code looks like this. [code]

View 8 Replies

Preserve An Array Inside A Class Method?

Mar 30, 2010

I have been learning about OOP and classes from a book and one of the question is the book has asked to create a simple Saving/Checking accounts Program. The question says that most of the functionality must be done through an Accounts Class, and this Acoounts class must inherit certain private fileds from an base class 'Transaction.

The question also says that data from the Saving/Checking accounts Program must be read to and from a text file, and these functions must be done within the Acounts class.

i have done everything the question asks to the best of my knowlegde and understanding but when it comes to storing and retieving data from the textfile i cannot utilise the array i created to store the textfile data onto it.

Bank Account.Write a program to maintain a person's Savings and Checking accounts. The program should keep track of and display the balances in both accounts, and maintain a list of transactions (deposits, withdrawals, fund transfers, and check clearings) separately for each account. The two lists of transactions should be stored in sequential files so that they will persist between program sessions.

Consider the form in Figure 11.12. The two dropdown combo boxes should each contain the items Checking and Savings. Each of the four group boxes corresponds to a type of transaction. (When Savings is selected in the Account combo box, the Check group box should disappear.) The user makes a transaction by typing data into the text boxes of a group box and pressing the button. The items appearing in the Transactions list box should correspond to the type of account that has been selected. The caption of the second label in the Transfer group box should toggle between "to Checking" and "to Savings" depending on the item selected in the "Transfer from" combo box. If a transaction cannot be carried out, a message (such as "Insufficient funds") should be displayed.

The program should use two classes, Transaction and Account. The class Transaction should have properties for transaction name, amount, date, and whether it is a credit (deposit) or debit (withdrawal/check). The class Account, which will have both a checking account and a savings account as instances, should use an array of Transaction objects. In addition, it should have properties for name (Checking or Savings) and balance. It should have methods to carry out a transaction (if possible), to display the list of transactions, and to load and retrieve the set of transactions into or from a sequential file. The events InsufficientFunds and TransactionCommitted should be triggered at appropriate times.

Hint: In order for an Account object to display a list of transactions, a list box should be passed to a method as an argument. The method might be declared with Sub EnumerateTransactions(ByVal lb As ListBox).

Here is my code. I am sorry this code is basic and unedited.

Public Class Form3
'load contents of Text file into the listbox when first loaded
'store data in file into array of accounts, record no. counts

[code]....

View 3 Replies

C# - Access A Shared/static Member Through An Instance Variable?

Mar 3, 2011

Here's an example of what I'm talking about...

Public Class Sample1

Public Shared Function MyValue() As Integer
Return 0
End Function
Public Sub Code()

[Code]...

Me.MyValue gives a warning in VB.NET and (the equivalent code gives) an error in C#. Is there a particular reason for this? I find it more intuitive/natural to access the shared function using 'Me.MyValue' - but I avoid it to keep my warnings at 0. Did someone else just decide 'Nah, it makes more sense to do it the other way' or is there some technical reason I don't understand?

EDIT: I was thinking of it wrong, more like a 'sub class' in OOP. Even if something is declared in the base class, you access it through the instance you have. But that relationship is not the same with shared or static.

View 6 Replies

Access Shared Variables Of A Class?

Jul 23, 2009

I am making a small application in which i have added a class module and a window forms in vb.net. i want to acess the shared variables and mathods of class without making any object.

View 8 Replies

Use Derived Class Shared Variables In Shared Methods Of Base Class?

Jun 4, 2010

I am trying to add shared members in derived classes and use that values in base classes...

I have base

class DBLayer
public shared function GetDetail(byval UIN as integer)
dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin)
end function
end class

[Code]..

currently there is error using the tablename variable of derived class in base class but i want to use it i dun know other techniques if other solutions are better then u can post it or u can say how can i make it work? confused...

View 2 Replies

Declared A Class Variable Inside Sub?

Jul 26, 2010

I have a text file to read, at the first line will have a size of array, that means I cannot guess size of array, and I have to create a array in side a sub (Local Variable). Then, I want to use value of array in another sub, but I cannot use value of variable of another sub. What I have to do to make an array con be used in every sub/function in a class? Also, I've post an example file, code and error list.

[Code]...

View 1 Replies

Access Of A Shared Member [...] In Custom Class?

Jun 9, 2012

I have a custom class called "Time" with the following function, for determining if one Time equals another Time.

Public Shared Shadows Function Equals(ByVal Time1 As Time, ByVal Time2 As Time) As Boolean
Dim x(2) As Integer
x(0) = CInt(Time1.Hour)
x(1) = CInt(Time1.Minute)

[code].....

Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.I know it shouldn't do any harm, just let the compiler skip evaluation, but is it a way of getting rid of this warning?

View 6 Replies

Access The Base Class Inside A Derived Class?

Oct 22, 2010

How do I access the base class inside a derived class?

View 1 Replies

Access A Shared Property Of The TestClass Class From The Page.aspx?

Jan 18, 2010

I have:

Page.aspx
Page.aspx.vb
TestClass.vb

I'm trying to access a shared property of the TestClass class from the Page.aspx.This code works fine:

<head>
<script language="JavaScript">
<% if System.Globalization.CultureInfo.CurrentCulture.Name.ToLower = "pt-br" Then %>[code]......

View 2 Replies

.net - Why Can't Call Private Shared Methods From A Public Shared Method

Aug 25, 2011

I have a class like this:

[Code]...

It works, when I make getBar methods public, but I don't want to expose these unneccessarily. Why I can't call private shared methods from a public one in the same class is over my head. I'm using .net framework 4.0 in a web application.

View 1 Replies

C# - Make A Variable/method/class Name Descriptive?

Aug 7, 2009

Sometimes to make a variable/method/class name descriptive I need to make it longer. But I don't want to, I'd like to have short names that are easy to read. So I thought of a special addin to IDE like Visual Studio to be able to write short names for class, method, field but be able to attach long names. If you need to - you can make it all long or you can make single name long. If you want to reduce it - use reduction, like two views of the same code. I`d like to know what others thinking about it? Do you think it is usefull? Would anybody use the kind of addin?

View 12 Replies

Shared Method Not Calling Shared Constructor

Aug 12, 2009

Given in the following language specification, for me at least, calling Db.Foobar() [In the following code] does not indeed call off to the Shared Constructors of the base classes. I am curious as to a) is this my own fault for doing something wrong or b) is this an error in the language specification[code]...

View 2 Replies

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

Asp.net - Public Shared Variable Shared Between Users?

Mar 30, 2012

I've taken over the maintenance of the website (ASP.NET VB) and on one particular page I noticed the below code

Inherits System.Web.UI.Page
Public Shared UserNumber As String
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

[Code]....

My question is whether the variable UserNumber can be accessed or changed by any other user than the current one?

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

Forms :: Form Object Access From Class Method

Oct 22, 2009

I want a string and a listbox, both which are in a form to be modified by an instance of a class method. Should (could I):

1. Pass the entire form to the class method as parameter.

2. Pass the listbox and the string to the method as parameters.

What's the best approach to get access and modify this string and listbox on the form.

View 3 Replies

Asp.net - Access A Module Or A Public Class With Public Shared Members From Inline Vb Code <% .. %>?

Feb 10, 2011

I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.

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







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