Store A Variable As Public And Use Throughout Application?

May 28, 2009

I have a query that brings back a result that I want to be able to use on all forms in my project. Is there a way to store this until the application is terminated?

For example,

I'd like to store the result of this:

Dim ssSQL As String = "SELECT ClaimNo, Custodian, Activity, Code, DateStamp FROM [Activities] WHERE "
ssSQL &= "[ClaimNo] Like ('" & txtClaimNum.Text & "')"

[Code].....

View 6 Replies


ADVERTISEMENT

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

Make A Variable Public To All Forms Within The Application?

Jun 9, 2011

how to make a variable public to all forms within the application.Eg

Public MyPath = "C:"

can do for one form but not all

View 3 Replies

Store Permanent Variable In Windows Application?

Jan 11, 2010

I'm making a windows form application using vb.net and have an options page where I need to allow users to enter a few settings, these need to be stored somewhere on the machine so that they can be found again if the program closes

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

What Is Different Between Global Variable And Public Variable

Jul 15, 2010

What is Different between global variable and public variable?

View 1 Replies

VS 2010 Public Dataset Or Table To Store Permissions Locally?

Dec 7, 2011

In my vb.net winforms application using Visual Studio 2010, I'm trying to work something out and my brain just isn't working today. I'm rewriting this application to make it more efficient and trying to minimize the sql calls.

Currently it works like this.User logs in to the app, it loads the main form, where the user can open up different forms to access different client data. Each time a record is loaded in one of these new forms it also loads that specific users permissions from a Sql Server 2005 table.

What I want to do is when my main form loads after the user logs in, is load a public dataset or datatable, or any other suggestion, storing that users permissions so I can access them locally without hitting the sql server every time the user opens a client record.

View 4 Replies

Store Variable Data Into Another Variable?

Feb 4, 2010

How can I store the value of a variable into another variable that wont be changed unless it meets certain criteria

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

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

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

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

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

Declare A Global (or Public?) Variable On Load?

Jun 13, 2012

Just working on getting more fluent in Visual Basic over the summer so I'm still sharp for my next visual basic class. My teacher went over variables, but only in local scope.I have looked everywhere, but I can't find exactly what I need. I'm making an alarm clock of sorts, and I have this code to populate the minute array and the hour array.

Public Class Form1
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[code].....

View 3 Replies

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

Set The Value Of A Public Class Variable To A Text Box Entry?

Apr 1, 2010

how to set the value of a Public Class variable to a text box entry?

I have a variable declared in the Public Class that was assigned to a public variable and I want to be able to have user entry via textbox.

If i change the variable to an integer and set it to textbox my program wont build.

View 1 Replies

VS 2008 Using Public Readonly Variable In A Module

Nov 29, 2009

I have a public readonly variable in a module, but when I try to set it in my form load event for the first time I get 'ReadOnly' variable cannot be the target of an assignment. It is my understanding that a ReadOnly variable can only be set once and after that you would get an error when setting it.

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

VS 2008 Data In A Variable Not Transmitting Between Public Subs?

Nov 17, 2009

Basicly I have a set of public subs, (not related to a form), inside a public class, and all of them share a variable. One of the subs, the one called for first gives the variable a value.

When the next sub is called, the variable is null. The data in the variable has been erased as the execution of the prior public sub ended I'm guessing.

View 7 Replies

Store 23:23:30 In A Variable?

Apr 14, 2009

i have 23:23:30 in a texbox and i like to store this in a variable ,if i put a variable m1 as decimal, i have a message error,if i put string , i have 0 and not 23:23:30,why?

View 11 Replies

Store Value From One Variable To Another?

Mar 11, 2010

How can I store the value of a variable into another variable that wont be changed unless it meets certain criteria

View 2 Replies

Min Date To Store In Variable In .net?

Jan 1, 2012

I got Minimum date from database using sql qry, And when i try to store that min.date in one variable, its getting error, PlZ help me. for below coding.

Dim qry as string
Dim Min_Date As Date
If SqlCon.State = ConnectionState.Closed Then
SqlCon.Open()

[code]....

View 2 Replies

Store / Appear In A Variable - A Textbox Value?

Feb 2, 2009

Can someone give me a simple example on how can I store/appear in a variable/or a textbox a value that i retrieved from a database. The sql query is something like "Select Comment from Params where id =1".

View 5 Replies







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