Interoperation / Office Integration Topics include: COM, P/Invoke (e.g. Win32 API), marshaling, distributed applications, VBA and interacting with office apps

Go Back  Xtreme .NET Talk > .NET > Interoperation / Office Integration > Convert integer to intptr


Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2005, 06:29 PM
stustarz stustarz is offline
Junior Contributor

Preferred language:
VB.NET
 
Join Date: Jan 2003
Location: Earth
Posts: 246
stustarz is on a distinguished road
Default Convert integer to intptr



Hi

In c# i can use:

Code:
'ListViewAPI.CDRF_DODEFAULT is an integer value
(IntPtr)ListViewAPI.CDRF_DODEFAULT
To convert an integer to type intptr, so how can i do it in VB, ive tried:

Code:
CType(ListViewAPI.CDRF_DODEFAULT,intptr)

But recieve an error stating i cant convert an integer to intptr.

Also.....

this in c#:

Code:
(nmcd.hdr.hwndFrom != Handle)
doesnt work when translated to vb, it states that the operator <> is not defined for types intptr to intptr!

Any c# and vb gurus who can help me out here?

Cheers
__________________
Visit: VBSourceSeek - The VB.NET sourcecode library


Quote:
"A mere friend will agree with you, but a real friend will argue."

Last edited by stustarz; 02-26-2005 at 07:19 PM. Reason: Amend code snippets
Reply With Quote
  #2  
Old 02-26-2005, 06:41 PM
HJB417's Avatar
HJB417 HJB417 is offline
Contributor

Preferred language:
c#, c++, j#
 
Join Date: Mar 2003
Location: Lowell, MA
Posts: 609
HJB417 is on a distinguished road
Default

c#
Code:
int value = 0xF;
IntPtr ptr = new IntPtr(value);
Reply With Quote
  #3  
Old 02-26-2005, 07:30 PM
stustarz stustarz is offline
Junior Contributor

Preferred language:
VB.NET
 
Join Date: Jan 2003
Location: Earth
Posts: 246
stustarz is on a distinguished road
Default

Sorry im not looking to know how to declare variables in c#

I am looking to convert c# into vb - in particular converting integers to intptrs and comparing two values of type intptr using the <> (vb syntax). Neither of these seem to work in VB yet are fine in c#
__________________
Visit: VBSourceSeek - The VB.NET sourcecode library


Quote:
"A mere friend will agree with you, but a real friend will argue."
Reply With Quote
  #4  
Old 02-26-2005, 07:36 PM
HJB417's Avatar
HJB417 HJB417 is offline
Contributor

Preferred language:
c#, c++, j#
 
Join Date: Mar 2003
Location: Lowell, MA
Posts: 609
HJB417 is on a distinguished road
Default

vb or vb.net?
Reply With Quote
  #5  
Old 02-26-2005, 07:39 PM
stustarz stustarz is offline
Junior Contributor

Preferred language:
VB.NET
 
Join Date: Jan 2003
Location: Earth
Posts: 246
stustarz is on a distinguished road
Default

Vb.net
__________________
Visit: VBSourceSeek - The VB.NET sourcecode library


Quote:
"A mere friend will agree with you, but a real friend will argue."
Reply With Quote
  #6  
Old 02-26-2005, 07:45 PM
HJB417's Avatar
HJB417 HJB417 is offline
Contributor

Preferred language:
c#, c++, j#
 
Join Date: Mar 2003
Location: Lowell, MA
Posts: 609
HJB417 is on a distinguished road
Default

I cheated and use roeder's decompiler to decomiple my code to vb.net
Code:
<STAThread> _
Private Shared Sub Main(ByVal args As String())
      Dim ptr1 As IntPtr
      Dim ptr2 As IntPtr
      Dim num1 As Integer = 3
      Dim num2 As Integer = 6
      ptr1 = New IntPtr(num1)
      ptr2 = New IntPtr(num2)
      Dim flag1 As Boolean = (ptr1.ToInt64 < ptr2.ToInt64)
      Console.WriteLine(flag1)
End Sub
Reply With Quote
  #7  
Old 02-26-2005, 07:51 PM
stustarz stustarz is offline
Junior Contributor

Preferred language:
VB.NET
 
Join Date: Jan 2003
Location: Earth
Posts: 246
stustarz is on a distinguished road
Default

thanks very much for the help, great idea about decompiling to vb, i convert c# to vb.net quite a bit, but can get a bit stuck when certain aspects of c# are completely different to the vb.net way!
__________________
Visit: VBSourceSeek - The VB.NET sourcecode library


Quote:
"A mere friend will agree with you, but a real friend will argue."
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert uint --> IntPtr JumpyNET General 5 06-07-2005 07:25 AM
converting IntPtr to Bitmap kjw Graphics and Multimedia 2 01-03-2005 09:31 AM
IntPtr to an array. wyrd General 1 06-20-2004 10:03 PM
IntPtr.Zero bogdandaniel General 1 09-05-2003 05:42 AM
convert system.color to integer ? (C#) dynamic_sysop General 8 06-08-2003 02:34 PM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe