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 6 3482
"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
"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")
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")
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
"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.
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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 (user-defined types).
The point is that for one of...
|
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 allocating memory for a new variable more...
|
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
|
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;
DECLARE end_date date;
SET start_date =...
|
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 variable
set to the name of the control to tell the...
|
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
WebForm2.aspx.
For declaring the property oRpte()...
|
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 folders, but web pages would be called across the 4...
|
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 and initializing variables inside a loop routine,...
|
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 < 10; i++) {
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |