473,387 Members | 1,621 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,387 software developers and data experts.

C# supports pointer.

What do we do for pointer in VB.NET?

Thanks
Nov 21 '05 #1
7 2924
"Rulin Hong" <Ru*******@discussions.microsoft.com> schrieb:
What do we do for pointer in VB.NET?


C# supports pointers only inside 'unsafe' blocks which are only useful in
some very rare cases. VB.NET gladly doesn't support them. What do you want
to archieve?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Dim ptr As IntPtr

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #3
"Crouchie1998" <cr**********@spamcop.net> schrieb
Dim ptr As IntPtr


hehe. :-))

Armin
Nov 21 '05 #4
>> Dim ptr As IntPtr

hehe. :-))


You guys are *evil*. Let me see some VB.NET code that dereferences ptr and
I'll be impressed.

--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
Nov 21 '05 #5
"Mike Labosh" <ml*****@hotmail.com> schrieb
Dim ptr As IntPtr


hehe. :-))


You guys are *evil*. Let me see some VB.NET code that dereferences
ptr and I'll be impressed.


dim b(499) as byte
Marshal.Copy(ptr, b, 0, 500)

msgbox b(17) 'reference to b(17)

;-)
Armin
Nov 21 '05 #6
Hello Rulin,

If you have an variable and you want its address:
~
Dim GCH as GCHandle = GCHandle.Alloc(YourVar, GCHandleType.Pinned)
REM now GCH.AddrOfPinnedObject is pointer to your var so do whatever you
want
GCH.Free()
~

On the other hand, if you have an address, you can get a value:
~
DesiredValue = CType(Marshal.PtrToStructure(YourPointer,
DesiredValue.GetType), TypeOfDesiredValue)
~
Note that this time you actually get COPY of the value.

Marshal and GCHandle are located in System.Runtime.InteropServices
namespace.

Hope this helps

Dragon

"Rulin Hong" <Ru*******@discussions.microsoft.com> сообщил/сообщила в
новостях следующее:
news:46**********************************@microsof t.com...
What do we do for pointer in VB.NET?

Thanks



Nov 21 '05 #7
Mike,
As Armin suggests, there are a number of methods on
System.Runtime.InteropServices.Marshal class that allows you to dereference
an IntPtr.

Marshal.Read* & Marshal.Write* may be "better" to use then Marshal.Copy. I
find Marshal.PtrToStructure & Marshal.StructureToPtr to be extremely useful
in some interop cases.

Of course Marshal.PtrToString* & Marshal.StringTo* are invaluable when
dealing with strings.

I've even used Marshal.GetObjectForIUnknown once or twice...

Hope this helps
Jay

"Mike Labosh" <ml*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
| >> Dim ptr As IntPtr
| >
| > hehe. :-))
|
| You guys are *evil*. Let me see some VB.NET code that dereferences ptr
and
| I'll be impressed.
|
| --
| Peace & happy computing,
|
| Mike Labosh, MCSD
|
| "Mr. McKittrick, after very careful consideration, I have
| come to the conclusion that this new system SUCKS."
| -- General Barringer, "War Games"
|
|
Nov 21 '05 #8

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

Similar topics

5
by: wylbur37 | last post by:
How do you find out what version of JavaScript your browser supports? Is there a JavaScript function that will tell you? __________________________________ Do you Yahoo!? Find out what made...
2
by: deba | last post by:
From the documentation of SOAP it seems SOAP supports both HTTP and TCP protocol.I did not find much documentation how to use TCP as transport layer in SOAP? Does the SOAP toolkit 2.0 supports...
3
by: VStennis | last post by:
I need to create a text editor that supports VS.Net like regions, where you can expand and collapse a certain part of the text when it is enclosed in #region - #endregion. Any suggestions or...
1
by: Wei-Chao Hsu | last post by:
On IA-32, 16 bytes float has supported in Fortran. Is there any C++ compiler supports 16 bytes float?
1
by: Ashabul Yeameen | last post by:
I am writing a program which at some point need to call fputwc() function. But since I want to make this code portable I've decided to write my own fputwc() funcion where the compiler doesn't...
1
by: Eitan | last post by:
Hello, I'd like to know whether C# supports COM objects, ActiveX ? Does this behaviour takes much different then old fashions visual studio C versions ? Need sample code, please. Thanks...
13
by: TomАs | last post by:
Let's start off with: class Nation { public: virtual const char* GetName() const = 0; } class Norway : public Nation { public: virtual const char* GetName() const
9
by: shailesh | last post by:
hi all, I m new joiny. I read that most of the compiler auto detect tail recursion in program. can any body tell me that is Code compoaser studio for TI dsp supports? rgds,
0
ADezii
by: ADezii | last post by:
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be: Can I add New Records to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.