472,328 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Declaring Variables

Hello,

I am using Visual Web Developer 2005 Express. I want to declare a varible,
using Visual Basic as the language and can't get anywhere. For example

Public Test1 as String

I'll get en error saying to change Public to Dim. When I do, it will say
that Test1 is an unused local variable.

Thanks for any help.

God Bless,

Mark A. Sam


Mar 11 '06 #1
6 3405

"Mark A. Sam" <ms**@Plan-It-Earth.Net> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am using Visual Web Developer 2005 Express. I want to declare a
varible,
using Visual Basic as the language and can't get anywhere. For example

Public Test1 as String

I'll get en error saying to change Public to Dim. When I do, it will say
that Test1 is an unused local variable.

Thanks for any help.

God Bless,

Mark A. Sam

and it is unused until you use it somewhere in your code.

GalenS

Mar 12 '06 #2

"Mark A. Sam" <ms**@Plan-It-Earth.Net> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am using Visual Web Developer 2005 Express. I want to declare a
varible,
using Visual Basic as the language and can't get anywhere. For example

Public Test1 as String

I'll get en error saying to change Public to Dim. When I do, it will say
that Test1 is an unused local variable.

Thanks for any help.

God Bless,

Mark A. Sam

Sounds like you are trying to declare a local variable, thus Public is not
an option.
You are also declaring a reference type (String), thus your declaration:

Dim Test1 as String

creates a String object variable that references nothing, hence the second
error.

Try something like this:

Dim xx As New String("THIS IS THE STRING")


Mar 12 '06 #3
Actually I'm just playing around trying to learn this stuff. I am
interested in Public variables, becuase I can see a use for them down the
road. Your example worked, but so should mine have worked. I followed the
example in Help. Do you know the syntax for declaring public variables? Do
I need to assign value to variables when they are declared?

Thanks.

Mark

Sounds like you are trying to declare a local variable, thus Public is not
an option.
You are also declaring a reference type (String), thus your declaration:

Dim Test1 as String

creates a String object variable that references nothing, hence the second
error.

Try something like this:

Dim xx As New String("THIS IS THE STRING")

Mar 12 '06 #4
Mark A. Sam <ms**@Plan-It-Earth.Net> wrote:
I am using Visual Web Developer 2005 Express. I want to declare a varible,
using Visual Basic as the language and can't get anywhere. For example

Public Test1 as String

I'll get en error saying to change Public to Dim. When I do, it will say
that Test1 is an unused local variable.


It sounds like you're putting that line of code inside a method, making
it a local variable. "Public" only makes sense for an instance or
shared variable.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 12 '06 #5

"Mark A. Sam" <ms**@Plan-It-Earth.Net> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Actually I'm just playing around trying to learn this stuff. I am
interested in Public variables, becuase I can see a use for them down the
road. Your example worked, but so should mine have worked. I followed
the example in Help. Do you know the syntax for declaring public
variables? Do I need to assign value to variables when they are declared?

Thanks.

Mark

To declare a public variable, do it within your class body, but outside any
code block.
Mar 12 '06 #6
Thanks. That works now. I thought I did that before without success.

Partial Class test

Inherits System.Web.UI.Page

Public variantTest As VariantType

Will this value be available from page to page?

"pvdg42" <pv****@newsgroups.nospam> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...

"Mark A. Sam" <ms**@Plan-It-Earth.Net> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Actually I'm just playing around trying to learn this stuff. I am
interested in Public variables, becuase I can see a use for them down the
road. Your example worked, but so should mine have worked. I followed
the example in Help. Do you know the syntax for declaring public
variables? Do I need to assign value to variables when they are
declared?

Thanks.

Mark

To declare a public variable, do it within your class body, but outside
any code block.

Mar 13 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Stefanie | last post by:
Hi, I have a question about declaring variables for writing data to a file for random access. I have two string variables declared in a module...
2
by: Oliver Corona | last post by:
I am wondering if anyone has any insights on the performance benefit (or detriment) of declaring local variables instead of referencing members. Is...
6
by: Joe | last post by:
Is it generally considered "better" (i.e. clearer) to declare all variables at the start of a function or as you need them within it? Joe
2
by: ross.oneill | last post by:
Hi, I am having trouble with a simple task of declaring a variable. Is this possible? Here is what I want to do. DECLARE start_date date;...
1
by: ColinWard | last post by:
Hi guys. I have a question about declaring variables. I do a lot of re-querying of controls in my database and I use the Set statement with a...
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on...
2
by: TARUN | last post by:
I have a question about declaring the Global.ascx: In VS.NET I create a Solution, and there are 4 projects under it. They are put under 4...
8
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring...
6
by: =?Utf-8?B?QUw=?= | last post by:
Hi I usually stick to the convention of not declaring variables in my bodies of "loops" (including foreach) ie int x; for (int i = 0; i...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.