473,516 Members | 3,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB .NET Pointers

Hello!
Can you tell me how to set pointer to variable in VB.NET
Thank you!
Nov 19 '05 #1
11 32058
Danijel,
VB.NET does not support pointers, so there is no way to 'set pointer to
variable'.

What are you attempting to do, there may be a intrinsic .NET method to do
it.

Hope this helps
Jay

"Danijel Babic" <da***********@zg.hinet.hr> wrote in message
news:bi**********@bagan.srce.hr...
Hello!
Can you tell me how to set pointer to variable in VB.NET
Thank you!

Nov 19 '05 #2
Hello,

"Danijel Babic" <da***********@zg.hinet.hr> schrieb:
Can you tell me how to set pointer to variable in VB.NET


Pointers (as known from C) are not supported in VB .NET. Maybe you want
to set a reference?!

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #3

"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:#r**************@TK2MSFTNGP10.phx.gbl...
Hello,

"Danijel Babic" <da***********@zg.hinet.hr> schrieb:
Can you tell me how to set pointer to variable in VB.NET
Pointers (as known from C) are not supported in VB .NET. Maybe you want
to set a reference?!

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


Yes i want to set reference

Nov 19 '05 #4
Pass it into your fucntion or sub as

public function myFunction(ByRef myVariable as String) as Object

or

public sub mySub(ByRef myVariable as Object) as Object

don't take this literally, the only thing important is the ByRef statemenet.

"Danijel Babic" <da***********@zg.hinet.hr> wrote in message
news:bi**********@bagan.srce.hr...

"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:#r**************@TK2MSFTNGP10.phx.gbl...
Hello,

"Danijel Babic" <da***********@zg.hinet.hr> schrieb:
Can you tell me how to set pointer to variable in VB.NET


Pointers (as known from C) are not supported in VB .NET. Maybe you want
to set a reference?!

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


Yes i want to set reference


Nov 19 '05 #5
Hello,

"Danijel Babic" <da***********@zg.hinet.hr> schrieb:
Pointers (as known from C) are not supported in VB .NET.
Maybe you want to set a reference?!
[...] Yes i want to set reference


\\\
Dim x As New Bla()
Dim y As Bla = x ' Set a reference.
..
..
..
Public Class Bla
...
End Class
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #6
Hi Danjiel,

What do you want to set a reference to, and to do what ?

Regards,
Fergus
Nov 19 '05 #7
I want to do something like this. I have array of user type variable and i
want to get and set data trough class

Public ReadOnly Property Data() As My_variable

Get

Return My_variable(number)

End Get

End Property

This example gets data from My_variable. When I type my_class.data. I get
complete list of all elements of My_variable. If i call my_class.data.name i
get my_variable(number).name which is what i want. The problem i to set data
to my_variable(number).name. If i try this:

set (byval value as my_variable) ' type of value must me my_variable

my_variable(number) = value

end set

my_class.data.name = "Something"

You see the problem. I can't pass string type and a get error

my_class.data.name is a value and therfore cannot be the target of an
assignment

Help me!

"Fergus Cooney" <wo****@tesco.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
Hi Danjiel,

What do you want to set a reference to, and to do what ?

Regards,
Fergus

Nov 19 '05 #8
Could it be because your public property is set to READONLY?

Little things like that prevent you from writing to a variable.

By the way, I just read an page in Dan Appleman's book (VB Concepts and
Code) that explains why we don't use pointers in .NET (even though there is
Int32Ptr). The primary reason is to prevent corropution of memory (useful
tool) so that you don't overrun your memory buffer and corrupt other data.

All pointers to unmanged code are done within mangaged wrappers that take
care of things like this within the CLR.

Plus, he comments that pointers are some countries ways of punishing war
criminals.

"Danijel Babic" <da***********@zg.hinet.hr> wrote in message
news:bi**********@bagan.srce.hr...
I want to do something like this. I have array of user type variable and i
want to get and set data trough class

Public ReadOnly Property Data() As My_variable

Get

Return My_variable(number)

End Get

End Property

This example gets data from My_variable. When I type my_class.data. I get
complete list of all elements of My_variable. If i call my_class.data.name i get my_variable(number).name which is what i want. The problem i to set data to my_variable(number).name. If i try this:

set (byval value as my_variable) ' type of value must me my_variable

my_variable(number) = value

end set

my_class.data.name = "Something"

You see the problem. I can't pass string type and a get error

my_class.data.name is a value and therfore cannot be the target of an
assignment

Help me!

"Fergus Cooney" <wo****@tesco.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
Hi Danjiel,

What do you want to set a reference to, and to do what ?

Regards,
Fergus


Nov 19 '05 #9
No i try without readonly. I have no more ideas how to do it

"CJ Taylor" <ct*****@mortonwelding.com> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
Could it be because your public property is set to READONLY?

Little things like that prevent you from writing to a variable.

By the way, I just read an page in Dan Appleman's book (VB Concepts and
Code) that explains why we don't use pointers in .NET (even though there is Int32Ptr). The primary reason is to prevent corropution of memory (useful
tool) so that you don't overrun your memory buffer and corrupt other data.

All pointers to unmanged code are done within mangaged wrappers that take
care of things like this within the CLR.

Plus, he comments that pointers are some countries ways of punishing war
criminals.

"Danijel Babic" <da***********@zg.hinet.hr> wrote in message
news:bi**********@bagan.srce.hr...
I want to do something like this. I have array of user type variable and i want to get and set data trough class

Public ReadOnly Property Data() As My_variable

Get

Return My_variable(number)

End Get

End Property

This example gets data from My_variable. When I type my_class.data. I get complete list of all elements of My_variable. If i call
my_class.data.name i
get my_variable(number).name which is what i want. The problem i to set

data
to my_variable(number).name. If i try this:

set (byval value as my_variable) ' type of value must me my_variable

my_variable(number) = value

end set

my_class.data.name = "Something"

You see the problem. I can't pass string type and a get error

my_class.data.name is a value and therfore cannot be the target of an
assignment

Help me!

"Fergus Cooney" <wo****@tesco.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
Hi Danjiel,

What do you want to set a reference to, and to do what ?

Regards,
Fergus



Nov 19 '05 #10
Hi again Danijel,

CJ is right about ReadOnly. Using it means that you can't have Set
within a Property.

From what I can understand of your code, you are protecting an array
with a Property. This should look more like:

Public Property Data (Index As Integer) As My_variable
Get
Return aMy_variable (Index)
End Get
Set
aMy_variable (Index) = Value
End Set
End Property

In use:
MyClass.Data (10) = MyVariableA
: : :
MyVariableB = MyClass.Data (10)

MyVariable is, of course, a variable of type My_variable.
The word Value in the Set represents whatever's on the right-hand side
of the assignment.

In your example you talk about assigning a string. This is impossible
because you have defined Data as working with values of type My_variable. If
strings are essential here, then either Data must be defined as of type
string, or your My_variable class must have a string member.

If we're not getting there, give us some of your actual code to look at.

Regards,
Fergus

ps. My_variable is a very bad name for a type/class. The name should reflect
what it means to you as a user of that class, not what it means to the
compiler.
Nov 19 '05 #11

This is some of the actual code

Private Index As Integer 'this i private variable for storing index

of array (Podatci)

Public Structure Struktura_Baze
Dim p1 As Integer
Dim p2 As String
Dim p3 As Double
End Structure

Private Podatci(100) As Struktura_Baze
I want to do this:

Class_name.data.p2 ="Something" 'Podatci(Index).p2 = "Something"
a = class_name.data.p3 'a = Podatci(Index).p3
how should look property of that class?


"Fergus Cooney" <wo****@tesco.net> wrote in message
news:ub*************@tk2msftngp13.phx.gbl...
Hi again Danijel,

CJ is right about ReadOnly. Using it means that you can't have Set
within a Property.

From what I can understand of your code, you are protecting an array
with a Property. This should look more like:

Public Property Data (Index As Integer) As My_variable
Get
Return aMy_variable (Index)
End Get
Set
aMy_variable (Index) = Value
End Set
End Property

In use:
MyClass.Data (10) = MyVariableA
: : :
MyVariableB = MyClass.Data (10)

MyVariable is, of course, a variable of type My_variable.
The word Value in the Set represents whatever's on the right-hand side
of the assignment.

In your example you talk about assigning a string. This is impossible
because you have defined Data as working with values of type My_variable. If strings are essential here, then either Data must be defined as of type
string, or your My_variable class must have a string member.

If we're not getting there, give us some of your actual code to look at.
Regards,
Fergus

ps. My_variable is a very bad name for a type/class. The name should reflect what it means to you as a user of that class, not what it means to the
compiler.

Nov 20 '05 #12

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

Similar topics

27
3366
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined as ff: typedef struct { float *data ; int count ;
3
3431
by: ozbear | last post by:
This is probably an obvious question. I know that pointer comparisons are only defined if the two pointers point somewhere "into" the storage allocated to the same object, or if they are NULL, or one-past the end of the object as long as it isn't dereferenced. I use "object" in the standard 'C' sense. Is there some special dispensation...
9
5042
by: Mikhail Teterin | last post by:
Hello! I'd like to have a variable of a pointer-to-function type. The two possible values are of type (*)(FILE *) and (*)(void *). For example: getter = straight ? fgetc : gzgetc; nextchar = getter(file); What type should I give to `getter' so that the compiler does not issue
12
4059
by: Lance | last post by:
VB.NET (v2003) does not support pointers, right? Assuming that this is true, are there any plans to support pointers in the future? Forgive my ignorance, but if C# supports pointers and C# and VB.NET get compiled into the same code, then I don't understand why VB.NET can't support pointers Thanks for any info Lance
14
2808
by: Alf P. Steinbach | last post by:
Not yet perfect, but: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip To access the table of contents, use the "Bookmarks" tab in Adobe Acrobat. Comments, corrections, praise, nits, etc., are still welcome!
92
5003
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers, but I just don't know. I don't like them because I don't trust them. I use new and delete on pure pointers instead. Do you use smart pointers?
4
3494
by: Josefo | last post by:
Hello, is someone so kind to tell me why I am getting the following errors ? vector_static_function.c:20: error: expected constructor, destructor, or type conversion before '.' token vector_static_function.c:21: error: expected constructor, destructor, or type conversion before '.' token
25
12989
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void *p, void *q) that will take any two pointers and decide whether they can be compared or not. I really can't think how to do this - any...
54
11910
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining the advantages of smart pointers endlessly (which are currently used in all our C++ software; we use the Boost smart pointers) as I'm seriously...
2
2964
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your standard dynamic address book program. Adding, and listing work just fine. However, deleting, editing and viewing relies on member function retAddress....
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.