-
June 28th, 2009, 09:23 AM
#1
[RESOLVED] Equivalent of IntPtr.
What is the equivalent of IntPtr of Vb.Net in Vb6? For example what'll be the equivalent of the following 2 lines in Vb6?
Dim htok As IntPtr
htok = IntPtr.Zero
Thanks.
-
June 28th, 2009, 12:45 PM
#2
Re: Equivalent of IntPtr.
IntPtr in VB 6 would mean Long, so your code would look like this
Code:
Dim htok As Long
htok = 0
-
September 17th, 2011, 10:39 AM
#3
Re: Equivalent of IntPtr.
-
September 20th, 2011, 10:45 AM
#4
Re: [RESOLVED] Equivalent of IntPtr.
That took long time to say thankya.
I'm not even sure if the answer is correct. Isn't IntPtr a pointer?
Ok, well forget I asked.
-
September 20th, 2011, 04:38 PM
#5
Re: [RESOLVED] Equivalent of IntPtr.
Originally Posted by WoF
Isn't IntPtr a pointer?
No; it's an integral type with the size of a pointer, IOW the machine word size. (See http://msdn.microsoft.com/en-us/libr...em.intptr.aspx) Actually, I always found the name a bit misleading...
Ok, well forget I asked.
No.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
September 21st, 2011, 08:27 AM
#6
Re: [RESOLVED] Equivalent of IntPtr.
Well, you live and learn.
But reading the description you pointed out, it rather seems to be an object with many methods.
-
September 21st, 2011, 08:37 AM
#7
Re: [RESOLVED] Equivalent of IntPtr.
Originally Posted by WoF
[...] it rather seems to be an object with many methods.
That's not uncommon in .NET. Even the plain vanilla Int32 has lots of them as well.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
September 21st, 2011, 09:06 AM
#8
Re: [RESOLVED] Equivalent of IntPtr.
Yeah, when I got in touch with .Net stuff, I read about those base classes and how classes can share common methods. It makes a plain memory variable look and operate like any other object and integrates perfectly into the philosophy and conventions of the language.
Yet, it's a bit bewildering at the first glimpse.
I suppose var.ToString is then the equivalent of Str(var) and var.GetType replaces the TypeOf var is construct.
-
September 21st, 2011, 10:05 AM
#9
Re: [RESOLVED] Equivalent of IntPtr.
Originally Posted by WoF
I suppose var.ToString is then the equivalent of Str(var) [...]
I have no experience with VB .NET, but yes, I think it will internally compile the latter as the former.
[...] and var.GetType replaces the TypeOf var is construct.
I wouldn't bet on that, however. In my primary (or rather only) .NET language C++/CLI there's a difference between var::typeid and var->GetType() (syntax based on the assumption that var is of a reference type). The former is evaluated at compile-time, the latter at runtime. And that doesn't just make a difference in terms of runtime performance, is may also yield a different result if var refers to an object of a type that is derived from that var originally was declared as.
EDIT: Ok, there actually is the difference pointed out above, but you're probably right; a TypeOf var is construct wouldn't make much sense if it was evaluated at compile-time...
Last edited by Eri523; September 21st, 2011 at 10:11 AM.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
September 21st, 2011, 10:11 AM
#10
Re: [RESOLVED] Equivalent of IntPtr.
I think this topic might help you understand the whole casting to strings etc. in .NET, WoF :
http://www.codeguru.com/forum/showthread.php?t=443873
-
September 22nd, 2011, 07:59 AM
#11
Re: [RESOLVED] Equivalent of IntPtr.
Yes, thanks, Hannes. That explains the ToString() so far.
Since I've noticed that all (or nearly all) .net objects have a ToString() method, you can get a string out from any object, whereas a VB6 Str() function always expects a numerical argument.
Though, the casting "as string" becomes not immediately obvious to me. I know type casting from C++ (not .net) which serves mostly to change a pointer's quality for the compiler. You might have a pointer to an array of integers or a struct of some type and might further want to treat this as an array of bytes, so you do a cast for the compiler to know how to treat a ptr++ or what a *ptr finally is.
Casting some object like a CommandButton as string doesn't sound so useful, whereas I think CommandButton.ToSring() might return the caption?
Mainly, what I wanted to know was, that if although the syntax like var.ToString() or var.GetType() suggests that var is some complex object having own methods which consume memory space, var indeed might still be a simple integer, consuming 4 bytes only, but sharing those common properties which in fact are equivalents to stuff we would do with functions or other constructs in VB6.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|