Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IP Input Mask (VB 6 SR 5)

    Im trying to create an input box (textbox or otherwise) that works in the same way as the one windows uses for IP Addresses.

    Would anyone know how to do this?

    For anyone not familiar with it, it only accepts number, is in the format of #.#.#.# and each number has to be between 1 and 255.

    Any tips, clues, links or complete solutions would be much appreciated thanks. A link to a "retail" component solution may also be a help.

  2. #2
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: IP Input Mask (VB 6 SR 5)

    Attached is a VB project to create an IPAddress Ocx. I've included the Ocx file.

    Add this to your toolkit and use it like a normal control.

    Regards,
    Kevin Bell

  3. The Following User Says Thank You to BigKev For This Useful Post:

    jhon_doe_dd (2015-05-07)

  4. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IP Input Mask (VB 6 SR 5)

    Wow, that is a great control!!!

    Thanks Kevin, thats solved all of my IP masking woes!!!

  5. #4
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IP Input Mask (VB 6 SR 5)

    I dont suppose it's possible to change the background colour of the control? I've tried changing the colours in the available options with no luck so far.

    Not to worry if it can't be done, the colour is a minor issue, im just pleased I can use it.

  6. #5
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: IP Input Mask (VB 6 SR 5)

    Sorry Phil, I didn't think to add things like setting colours to the control. I don't think I've ever changed the background colour of this control or a text box either come to think of it.
    You'll also see that a lot of the other common properties aren't catered for either such as the ability to resize it.

    I'll see what I can do to add some of the more common properties if I have the time. (It's our year end so I'm a tad busy at the moment.)

    Regards,
    Kevin Bell

  7. #6
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IP Input Mask (VB 6 SR 5)

    The control is working perfectly at the moment, so the rest is just cosmetic so there certainly isnt any rush for it (and I know how busy year ends can get!!!).

    Whenever you find yourself free will do. Thanks again for the control and any further work you do on it. With controls like that you should set yourself up a website and sell them!

  8. #7
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: IP Input Mask (VB 6 SR 5)

    The control actually already exists in the Windows Common Controls collection but for some reason isn't included in the controls available to VB/VBA.

    The CreateWindowEx class name of "SysIPAddress32" along with the "ICC_INTERNET_CLASSES = &H800" parameter of the "INITCOMMONCONTROLSEXtype" type tells Windows to create an IP Address control.

    The IPM_GETADDRESS and IPM_SETADDRESS messages to the window cause the window to process and pass the values typed.

    I created the code by translating the documentation I found in the MSDN under MSDN Home > MSDN Library > User Interface Design and Development > Windows Shell > Windows Controls > Individual Control Information > IP Address Controls

    As an aside, please note that the IPAddressAsLong version returns/sets an IP address in host byte order. Therefore you'll need to run the returned value through htonl before you pass it to any wsock32 functions.

    Regards,
    Kevin Bell

  9. #8
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IP Input Mask (VB 6 SR 5)

    Thanks for the additional info Kevin.

    At the moment, all the apps I've been writing have been using wininet FTP so the IPAddressAsString variable is perfect for the job.

    If I get a chance I'll take a look on MSDN but we're in the middle of an update for an App that, lets just say, has been a bit lacking on the testing side - so its a bit manic at the moment!

Posting Permissions

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