Create A Global Function To Use Throughout The Application?

Jul 7, 2011

I want to create a global function to use throughout my application. Let say it's about the connection to the database.My code that i plan to use in my global function is:

myConnection = New SqlConnection("...........")
myConnection.Open()

So that I can call it to use in every form throughout my application. This can make me easy to edit the connection later.how to define this global function and how to call this function in the form.

View 2 Replies


ADVERTISEMENT

Create A Global Function?

Jul 12, 2009

If there's a way to have a function, that i can call from any code-behind on my website.

for example, i want to be on any page of my website, and be able to call this function[code]...

View 17 Replies

.net - Global RegEx Replace Function To Create HTML From Square Brackets?

Nov 30, 2011

I have some existing code that looks something like this:

[tag:cb cbid="12345" cbwidth="200" cbclassname="calloutbox" cbposition="left"] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
[tag:cb cbid="123" cbwidth="200" cbclass="calloutbox2" cbposition="left"] Suspendisse eleifend enim a magna pretium porttitor.

I need to write a VB .Net global function that will match these [tag:cb] and take the optional parameters and rewrite the string with Html tags.

<div id="12345" width="200" class="calloutbox" position="left">content (based on id)</div>

View 1 Replies

Create A License Key Function For Application?

Apr 24, 2010

I want to create a license key function for my application.

For example I want in this key to contact 2 values: registered_to, expiry_date.

I want the licence key to be some sort of large string like: 2349ASDGKLASD87ASDGALSDK8ASD80972K.

I would need to create some way to create keys use some sort of algorhithm that decrypts the key and grabs the registered_to and expiry_date values. It also needs to check that the key string has some sort of check digit like credit cards have, so no-one can just type in a few random letters/numbers and it accepts.

View 2 Replies

Adding A Global Function?

Nov 16, 2009

I am trying to add a new global function

I am doing it like that:

Function MessageYNC() As String
{
return "dd";
}

[Code].....

But i am getting error -> Statement is not valid in a namespace. on the first line

View 2 Replies

Accessing Global Function / Values?

Jun 1, 2009

m using a public variable called globalquery & a global function retriveToDataGrid() it works perfectly fine under same class /form ..... but when i try to access it from a different form , it gives no error and nothing happens

Public Sub retriveDataToDataGrid()
Try
Dim connStr As String = "Database=shahopticals;" & _
"Data Source=localhost;" & _

[code]....

View 16 Replies

Use Function Return In Global Variable?

Jun 3, 2010

Can't seem to figure out how to use a function return variable in global Dims[code]...

I have also tried adding "FixPath()" under Sub On_load() but got same result. Also the reason I have to have these global is because I have around 30 Subs that refer to "Path" Variable.

View 1 Replies

Call New Class With Global Scope From Function?

Dec 4, 2011

I want to create a new instance of a class when I click on a button, but I need to interact with members of that class using other controls on the form, so I need the class to have a global scope. I know I could call the new class in formload, but the class creates certain variables that need to be current. If it is done on formload, the variables wouldn't be current, because if the class is created at formload, it would have different info at that time. Surely, there must be a way to create an instance of the myClass from within a sub that is accessible from other subs of the same class.

[Code]...

View 2 Replies

Create A Global Dataset?

Dec 27, 2010

I want to create a dataset that I can access from any form. I already created the tables and columns using the dataset designer. I read that I can declare the dataset as public in a module, but when I try to access a table I have to put the name of the module in front otherwise I get a "Reference to a non-shared member requires an object reference" error. When I declare a variable as public in a module I never have to specify the name of the module to access the variable, so why do I need to do it for a dataset? The code in my module is:

[Code]....

View 5 Replies

Create A Global Variable?

Oct 11, 2010

How Can I create a Global Varibale for my vb.net project. When I LongIn I want to keep the user Id in a varible and I will Use it in deferent Forms. And The User name will be saver in the varible untill I close the Software.

View 1 Replies

Create Global Object In .NET?

Apr 1, 2011

I'm trying to build a language dictionary in VB NET in order to be able to have several languages in the application.This dictionary has a init method that loads from database the entire dictionary and stores it in memory.In the rest of the classes of the project, I added the reference and I can use directly the object without create a new instance because their methods are shared.

how i have to load the dictionary content in order that the rest of classes only accessing to Language.GetWord method obtains the properly record of the collection, same way as My.Settings class.When My.Settings is used from any class the values are loaded. I'm looking for the same effect.This is the code of the class:

Public Class LanguageProvider
Private Shared CurrentLanguage As Collection
Public Shared ReadOnly Property GetWord(ByVal Label As String)

[code]....

Function LoadLanguage must be called when the application loads, in order to access once to database. After that property GetWord must access to the collection with the words and return the result. The problem is that the instances are not the same and the dictionary is not loaded when a class uses it.

View 1 Replies

How To Create DLL From Global Source

Feb 13, 2012

I want to add this to my visual studio. [URL]. I understand I should ad it like normal custom dll. but how do i get the dll file from the zipped source.

View 2 Replies

Create A Combobox As A Global Variable?

Jul 28, 2011

Where and how do i create a global variable for a combobox? I need to use it on different forms.

View 6 Replies

How To Create A Global Variable In VB 2008

Jan 17, 2012

Okay, Im a newbie to VB, so how do you create a Global variable inside a sub.

View 6 Replies

Create A Global Variable/config File?

Dec 4, 2009

how to create a global variable for this situation: I would like to store who logs in to a system (like, who is currently logged in, when he logged in) and then use that info for a transaction form, which will look like this: which admin made the transaction).

If I were to use a global variable, it would mean having to pass it onto several forms right (eg: from login form to the forms that will use the log information). I'm also thinking of just having a config file that will store the said login info that will be changed everytime a user logs in.

View 5 Replies

Global Instance In MDI Application

Apr 29, 2011

given a MDIParent Form and 2 MDI Children: frmChild1, frmChild2..How can i realize a Instance of MyClass in MDIParent, which I can read and write from frmChild1 and frmChild2 , too

View 4 Replies

C# - Application Variables Global To Webgarden?

Jan 12, 2010

I am currently trying to program an online drawing program using the HTML5 canvas.the thing is, I need to have the current canvas saved somewhere globally. Static variables work, but they do not get shared across a Webgarden. This results in two different drawings being created.I will have to somehow create a new application object which is shared. I figured I will need an external application holding them.

1) How do I replace the application object with my own?
So either I will have to make my own program and call to it with remoting or use the ASP.NET session state server for application variables. I favor the Session State Server though.

2) How do I use the session state server for my own variables? How do I access it?

I searched high and low on the internet and only found the ideas mentioned above, but no help executing them.

I mainly code in VB.NET, but I can also understand C# code for examples.

A little info on my application:The client side has two canvas objects on top of each other. The top canvas object us used for drawing stuff, the canvas object below it holds the drawing in the end.When something is drawn, it is sent to the server in it's base64 representation. (getDataUri).The server puts this graphic on top of a stored Bitmap object through a Graphics object.

How the changes are being distributed to the other clients, I am working on that right now. Either I transfer the complete picture or each and every change that is submitted. This should work through Server Push. If this does not work thoroughly I will have to save and timestamp changes. A link to the current implementation, which is not currently fetching changes (but they get transfered to the server... With the problem that some reach one instance some reach the other on either w3wp in the webgarden) from the server is here: http:[url].....

View 1 Replies

Defiine A Global Variable For The Whole Application?

Aug 26, 2009

How do I defiine a global variable for the whole application so that it does not have to be defined in all the forms that need it.

View 6 Replies

Global Hotkey Working For Application

Mar 17, 2012

I have implemented a global Hotkey into my code but the problem is that when I move the focus from the form to IE (For Example) i cannot use the Hotkey from my application. Everything is working great if I was to stay int the form but that's not the purpose of this code.

Private Sub frmMain_Load(ByVal sender As System.Object, e As System.EventArgs) Handles MyBase.Load
RegisterHotKey(Me.Handle, 9, MOD_ALT, VK_F9)
End Sub
Private Sub frmMain_FormClosing(ByVal sender As Object, e As
[Code] .....

View 8 Replies

.net - Global Entity Framework Context In WPF Application?

May 20, 2010

I am in the middle of development of a WPF application that is using Entity Framework (.NET 3.5). It accesses the entities in several places throughout. I am worried about consistency throughout the application in regard to the entities. Should I be instancing separate contexts in my different views, or should I (and is a a good way to do this) instance a single context that can be accessed globally?

For instance, my entity model has three sections, Shipments (with child packages and further child contents), Companies/Contacts (with child addresses and telephones), and disk specs. The Shipments and EditShipment views access the DiskSpecs, and the OptionsView manages the DiskSpecs (Create, Edit, Delete). If I edit a DiskSpec, I have to have something in the ShipmentsView to retrieve the latest specs if I have separate contexts right?

If it is safe to have one overall context from which the rest of the app retrieves it's objects, then I imagine that is the way to go. If so, where would that instance be put? I am using VB.NET, but I can translate from C# pretty good. I just don't want one of those applications where the user has to hit reload a dozen times in different parts of the app to get the new data.

All contexts are created in Using Blocks to dispose of them after they are no longer needed.When loaded, all entities are detatched from context before it is disposed.A new property in the MainViewModel (ContextUpdated) raises an event that all of the other ViewModels subscribe to which runs that ViewModels RefreshEntities method.After implementing this, I started getting errors saying that an entity can only be referenced by one ChangeTracker at a time. Since I could not figure out which context was still referencing the entity (shouldn't be any context right?) I cast the object as IEntityWithChangeTracker, and set SetChangeTracker to nothing (Null).

This has let to the current problem:When I Null the changeTracker on the Entity, and then attach it to a context, it loses it's changed state and does not get updated to the database. However if I do not null the change tracker, I can't attach. I have my own change tracking code, so that is not a problem.

My new question is, how are you supposed to do this. A good example Entity query and entity save code snipped would go a long way, cause I am beating my head in trying to get what I once thought was a simple transaction to work.

View 2 Replies

Application Like A Shopping Cart - Global Variable?

Dec 27, 2011

My project is to create a shopping cart application. I have my main form and from there the user can go to two different forms to add books to their cart, the cart being the main form. This all works. What I can't figure out, is how to use global variables for the prices, shipping, tax and updating the total. I have places for this information to show up on the main form, and I've created a module for the calculations and prices, but I don't know how to code it to get the prices to show up in the specified areas.

View 3 Replies

Approach For Handling Global Application Object?

Jun 15, 2009

What is the recommended way in VS.NET to have a global application handler object? Something that can load/verify/return user folders, settings, application specfic settings, manage the unhandled exceptions, etc. I would have a class that has most of the code, then subclass it for each application.

I can create one if I start as a module instead of a form. But then I lose some options such as NetworkAvailabilityChanged, etc. I define a "Public" object from within a form (I don't think so and don't feel this would be the right approach.)?can I "attach" an object to an existing global object store (such as "My."), etc.?

Once created, any object in my application should be able to reference methods/properties of this application object to get default folders, user values, etc. as necessary.

View 6 Replies

C# - .NET Global Exception Handler In Console Application?

Jun 28, 2010

I want to define a global exception handler for unhandled exceptions in my console application. In asp.net, one can define one in global.asax, and in windows applications /services, one can define as below

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyExceptionHandler);

But how can I define a global exception handler for a console application ?currentDomain seems not to work (.NET 2.0) ?

View 4 Replies

Changing The Object Declarations To Global Using The 'global' Keyword Evertime?

Mar 15, 2012

evrytime i add new controls to a form in vb.net the designer regenerates code and asks me to make corrections, so i have to keep on changing the object declarations to global using the 'global' keyword evertime it regenarates code,especialy dataset objects.how can i prevent this?

View 1 Replies

VS 2008 Project / Application Global OleDbConnection Object

Jun 17, 2009

I need a single, global OleDbConnection. One which will be available to use throughout my app/project. Another project like a custom UserControl? I should mention I'm not using TableAdapters, BindingNavigitor, etc. The datasource is not associated with my project. I communicate with the Db through code I write. I'm just a hack trying to ride with the big dogs while I develop an app for my job... We were/are in the stone-age!!!

View 7 Replies

Use Global X As String In Vb6 In A Module To Declare It With Global Privelages?

May 1, 2009

i could use Global x as string in vb6 in a module to declare it with global privelages, how can i do this in vb2008? how to declare a global variable in vb2008? so that i could use it anywhere i want. i know global variables are not recommended in programming but i need one.

View 4 Replies

Exception Handling In Winforms Application Using A Global Error Handler?

Sep 9, 2009

I have a Windows Form application that has a global error handler to display unexpected errors.

Namespace My
Class MyApplication
Delegate Sub ProcessParametersDelegate(ByVal sender As Object, ByVal args() As String)

[code]....

1) for the same deployed code, I SOMETIMES get line number in the displayed StackTrace error message and sometimes do not, even when the error message includes source code that I have written rather than a referenced binary. The project is compiled with a DEBUG configuration.

2) The application strangely minimizes to the tray when the error occurs (I thin it is unlikely that anyone can diagnose this issue w/o my more code posted, but I'll mention it anyways)

3) When I try to intentionally raise an error by, for example, dividing by zero hoping to test by global error handler, I get a dialog error message from the interactive debugger rather than jumping into my global error handler (which i want to debug because there is more to it than I posted.) Do you have any idea how to triggerand force teh execution of the global event handler?

View 2 Replies

Asp.net - Create Function To Create Thambnails Of Available Images In A Folder

Aug 28, 2009

I have create a CMS to upload all image to a folder using ed all my images to a folder using,

file.SaveAs(Server.MapPath("../images/") + advertID.ToString + "_" + i.ToString + fileExt)

Now, all images are saved and i forgot it create thumbnails. :(

I need to read all images at once and create thumbnails,

myimg = System.Drawing.Image.FromFile(imgFileName)
myimg = myimg.GetThumbnailImage(154, 94, Nothing, IntPtr.Zero)
myimg.Save(Server.MapPath("../Content/") + "Thumb_" + imgFileName, myimg.RawFormat)

I need this to function fast. I don't seems to know how to read these image names one by one.

View 1 Replies

Create A Global Object But Have The Events Within That Object Fire On A Separate Thread?

Oct 26, 2009

I have an object that is defined as a global variable based on custom class. Within that class I have an event that gets fired a certain intervals. These events are fired on the same thread as where the object is declared. How do I create a global object, but have the events within that object fire on a separate thread?

View 2 Replies

Create A "Global" Instance Of A Class?

May 30, 2012

I have a Public Class named UserData which consists of Login and Password properties, as well as various permissions related properties.

I declare an instance of this class in a Public Module (named DatabaseFunctions) as

Public User As New UserData Functions in that module are able to access the instance as expected. How do I access said instance from outside of the module?

Until now, I've only needed to utilize the information within that instance from within the module, so I didn't realize that I wasn't able to access it externally. Now, I need to display data contained in that instance on a form.

I had assumed I would be able to use User.Login outside of the function in which it was declared, since everything was declared as Public, but it seems I was mistaken.

View 3 Replies







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