Charlie Stuart
Charlie Stuart

Reputation: 272

Windows Phone - Accessing a variable from another page

I am creating a Windows Phone App which allows the user to post to twitter, however i have one page that is used to authorize the access to the persons twitter and it is on this page where several variables are given values. I then have another page where i let the user write and post the tweet, but in order to post it i need to be able to access these variables from the other page, how would i do this?

I have already tried to write something like:

Pagename.variablename

But it is inaccessible.

Also i am writing in VB.NET

Upvotes: 1

Views: 455

Answers (2)

A.K.
A.K.

Reputation: 3331

You could declare the variable static like

public static int amount;

and now this static variable can be used anywhere with the class name.

Likewise declare a variable in app.xaml.cs

public static string VarName;

and this variavble can now be used anywhere in the app like

App.VarName= "Hello";

Upvotes: 3

BestR
BestR

Reputation: 679

Make variablename static. it means, declare it like this:

Public Shared variablename As String = ""

Then you can assign it and use it later from any where.

When you want to access it, you will need to add "&". For example:

MessageBox.Show("this is the variable" &PageName.variablename)

Upvotes: 2

Related Questions