473,320 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

variable question

Hey all,

Given:
strVal1 = array.getvalue(0)
Is there a way I can have a variable in place of strVal1 that will point to
strVal1. I guess what I'm asking is if there's a way to make a variable point
to another variable?

Also, please give any opinions about this.

thanks,
rodchar
Nov 21 '05 #1
5 1102
"rodchar" <ro*****@discussions.microsoft.com> schrieb:
Given:
strVal1 = array.getvalue(0)

Is there a way I can have a variable in place of strVal1 that
will point to strVal1. I guess what I'm asking is if there's a
way to make a variable point to another variable?


Why? You can reference /objects/, which are instances of classes, not
variables.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
"rodchar" <ro*****@discussions.microsoft.com> wrote in message news:C7**********************************@microsof t.com...
Hey all,

Given:
strVal1 = array.getvalue(0)
Is there a way I can have a variable in place of strVal1 that will point to
strVal1. I guess what I'm asking is if there's a way to make a variable point
to another variable?

Can you give a more spesific context to this problem?
If strVal is private inside a class, then you can use a Property to referance to it from the oustide.
class myclass
private strVal as String

public property myVal as string
get
'some other code here perhaps...
return strVal
end get
set (Value as String)
if Value.Length >0 then strVal = Value
end set
end property
end class

From the outside you will se this as myclass.myVal

Dim m as new myclass
m.myVal = "hello world"
Dim s as string = m.myVal

You can even have ReadOnly or WriteOnly Properties, that can only be read or written to. The example above you can do both.

Also, please give any opinions about this.

thanks,
rodchar

Nov 21 '05 #3
I'm trying to see if there's a way to streamline the following:

Dim eeCode, eeRate, erCode, erRate As String
Dim tb As TextBox

tb = CType(e.Item.Cells(1).Controls(0), TextBox)
eeCode = tb.Text
tb = CType(e.Item.Cells(2).Controls(0), TextBox)
eeRate = tb.Text
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
erCode = tb.Text
tb = CType(e.Item.Cells(4).Controls(0), TextBox)
erRate = tb.Text

"Jarod_24" wrote:
"rodchar" <ro*****@discussions.microsoft.com> wrote in message news:C7**********************************@microsof t.com...
Hey all,

Given:
strVal1 = array.getvalue(0)
Is there a way I can have a variable in place of strVal1 that will point to
strVal1. I guess what I'm asking is if there's a way to make a variable point
to another variable?


Can you give a more spesific context to this problem?
If strVal is private inside a class, then you can use a Property to referance to it from the oustide.
class myclass
private strVal as String

public property myVal as string
get
'some other code here perhaps...
return strVal
end get
set (Value as String)
if Value.Length >0 then strVal = Value
end set
end property
end class

From the outside you will se this as myclass.myVal

Dim m as new myclass
m.myVal = "hello world"
Dim s as string = m.myVal

You can even have ReadOnly or WriteOnly Properties, that can only be read or written to. The example above you can do both.

Also, please give any opinions about this.

thanks,
rodchar


Nov 21 '05 #4

"rodchar" <ro*****@discussions.microsoft.com> wrote
I'm trying to see if there's a way to streamline the following:

Dim eeCode, eeRate, erCode, erRate As String
Dim tb As TextBox

tb = CType(e.Item.Cells(1).Controls(0), TextBox)
eeCode = tb.Text
tb = CType(e.Item.Cells(2).Controls(0), TextBox)
eeRate = tb.Text
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
erCode = tb.Text
tb = CType(e.Item.Cells(4).Controls(0), TextBox)
erRate = tb.Text

Not much, because you're using separate variables for the
different strings. (eeCode, ccRate ...) Had you made them
an array of strings, you could fill it within a loop. (if, for
example, you were filling up to 15 or 20 such strings, a loop
would add a significant reduction)

Even if you want to keep individual variables, you can remove
some of that code because VB will let you initialize variables
as you declare them, such as:

Dim eeCode As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim eeRate As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
.... etc ...

Using a With block you could remove even more:

With e.Item
Dim eeCode As String = CType(.Cells(1).Controls(0), TextBox).Text
Dim eeRate As String = CType(.Cells(2).Controls(0), TextBox).Text
.... etc ...
End With

But (with separate variables) that is about as far as you can go.

HTH
LFS
Nov 21 '05 #5
thank you very much, i'll take it.

"Larry Serflaten" wrote:

"rodchar" <ro*****@discussions.microsoft.com> wrote
I'm trying to see if there's a way to streamline the following:

Dim eeCode, eeRate, erCode, erRate As String
Dim tb As TextBox

tb = CType(e.Item.Cells(1).Controls(0), TextBox)
eeCode = tb.Text
tb = CType(e.Item.Cells(2).Controls(0), TextBox)
eeRate = tb.Text
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
erCode = tb.Text
tb = CType(e.Item.Cells(4).Controls(0), TextBox)
erRate = tb.Text

Not much, because you're using separate variables for the
different strings. (eeCode, ccRate ...) Had you made them
an array of strings, you could fill it within a loop. (if, for
example, you were filling up to 15 or 20 such strings, a loop
would add a significant reduction)

Even if you want to keep individual variables, you can remove
some of that code because VB will let you initialize variables
as you declare them, such as:

Dim eeCode As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim eeRate As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
.... etc ...

Using a With block you could remove even more:

With e.Item
Dim eeCode As String = CType(.Cells(1).Controls(0), TextBox).Text
Dim eeRate As String = CType(.Cells(2).Controls(0), TextBox).Text
.... etc ...
End With

But (with separate variables) that is about as far as you can go.

HTH
LFS

Nov 21 '05 #6

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

Similar topics

44
by: Mohanasundaram | last post by:
int i = 10; int main() { int i = 20; return 0; } Hi All, I want to access the global variable i inside the main. Is there
4
by: Gery D. Dorazio | last post by:
Gurus, If a static variable is defined in a class what is the scope of the variable resolved to for it to remain 'static'? For instance, lets say I create a class library assembly that is...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
3
by: James Robertson | last post by:
I am new to the ASP and VB thing so be kind. Question I have is that I have created an ASPX web site to use as an E-Mail page. But I want to use this for a lot of users. Can I create the link on...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
53
by: fdmfdmfdm | last post by:
This is an interview question and I gave out my answer here, could you please check for me? Q. What are the memory allocation for static variable in a function, an automatic variable and global...
37
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
5
by: somenath | last post by:
Hi All , I have one question regarding scope and lifetime of variable. #include <stdio.h> int main(int argc, char *argv) { int *intp = NULL; char *sptr = NULL;
19
by: Hapa | last post by:
Does only reading (never writing) of a variable need thread synchronisation? Thanks for help? PS. Anybody knows a Visual C++ news group?
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
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
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.