Results 1 to 6 of 6

Thread: Form handle in VB .NET

  1. #1

    Thread Starter
    Member Penavin's Avatar
    Join Date
    Oct 2001
    Location
    Sisak, Croatia
    Posts
    42

    Question Form handle in VB .NET

    Hi!

    How to get form handle in VB .NET? In VB 6 I use this:

    Code:
    Dim wHandle as Long
    
    wHandle = frmMain.hWnd
    Thank you!
    Penavin

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    In .NET , we do it like so
    VB Code:
    1. Dim lng As Long = Me.Handle.ToInt32

  3. #3
    Junior Member Guile.NET's Avatar
    Join Date
    Mar 2003
    Location
    www.voodoochat.com
    Posts
    31
    Int32 is an Integer data type.

    VB Code:
    1. Dim hWnd as Integer = Me.Handle.ToInt32
    The arrow shot by the archer may, or may not, kill a single person. However, stratagems devised by a wise man, can kill even babes in the womb.

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Or just leave it an IntPtr. That way it won't overflow as soon as you run the app on a 64 bit OS. It depends what you want to do with it though.

    VB Code:
    1. Dim hWnd as IntPtr = Me.Handle
    Frans

  5. #5
    Junior Member Guile.NET's Avatar
    Join Date
    Mar 2003
    Location
    www.voodoochat.com
    Posts
    31
    I learn something new everyday. =)
    The arrow shot by the archer may, or may not, kill a single person. However, stratagems devised by a wise man, can kill even babes in the womb.

  6. #6

    Thread Starter
    Member Penavin's Avatar
    Join Date
    Oct 2001
    Location
    Sisak, Croatia
    Posts
    42

    Smile Thank you!

    I thank to all of you for help.
    Penavin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width