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 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/>
"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
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
"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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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
|
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...
|
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) {
.....
}
|
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...
|
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:...
|
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...
|
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...
|
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;
|
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?
|
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...
|
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: 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...
|
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: 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....
|
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: 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...
| |