PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
IP Textbox User Control-VBForums
Results 1 to 16 of 16

Thread: IP Textbox User Control

  1. #1

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    IP Textbox User Control

    VS 2005/.NET 2.0

    I made this user control to mimic the IP textbox in the Windows TCP/IP settings. It's different than a masked box or just straight custom validation, in that it is actually 4 textboxes that look like 1 textbox.

    If you check the TCP/IP settings in Windows, you will see that this is how their box behaves. It works pretty well. Please let me know any comments/suggestions.

    Attached is the full source code, and a sample project showing it in action. Since I did not include any compiled code, you need to build the project before you view form1.
    Attached Files Attached Files
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  2. #2
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Re: IP Textbox User Control

    That looks ideal! How do I add that custom control to my project?
    ManagePC - the all-in-one PC management and inventory tool

  3. #3

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: IP Textbox User Control

    From your project just select "Add existing item" and find the IPTextBox.vb file from my project. Once you add it to your project, build your project and the control will appear in your toolbox.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  4. #4
    Junior Member
    Join Date
    Dec 2006
    Posts
    22

    Re: IP Textbox User Control

    Firstly Great stuff!! I tried to create a IP masked textbox in VB2005 using 099.099.099.099 but this didn't quite give me the result I was looking for.

    Couple of suggestions for this but it could be what you mean by user controls.

    1, When a . is pressed it moves to the next box or a backspace on the last char in a box moves you to the last box

    2, Copy and paste function - ability to copy the content or paste content in

    If you could point me in the right direction that would be much appreciated

    Thanks
    Last edited by Robbrad182; Dec 20th, 2006 at 04:41 AM.

  5. #5
    Junior Member
    Join Date
    Dec 2006
    Posts
    22

    Re: IP Textbox User Control

    Fixed the when you press a dot it tabs I used

    VB Code:
    1. Private Sub txtIP_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtIP1.KeyPress, txtIP2.KeyPress, txtIP3.KeyPress, txtIP4.KeyPress
    2.         Dim txtBox As TextBox = DirectCast(sender, TextBox)
    3.         'ONLY ALLOW CONTROL CHARS (LIKE BACKSPACE) AND NUMBERS TO BE ENTERED
    4.         Select Case Char.GetUnicodeCategory(e.KeyChar)
    5.             Case Globalization.UnicodeCategory.Control, Globalization.UnicodeCategory.DecimalDigitNumber
    6.             Case Else
    7.                 e.Handled = True
    8.         End Select
    9.         Debug.Print(e.KeyChar.ToString)
    10.  
    11.         If e.KeyChar = "." Then
    12.             Me.SelectNextControl(txtBox, True, True, False, False)
    13.         End If
    14.     End Sub

    Still not sure about the copy paste tho..

  6. #6

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: IP Textbox User Control

    do you mean copy/paste an entire IP into the box?

    Since the user control was build to behave like the windows IP entry box, it is actually made up of 4 textboxes. So you can't copy/paste an entire IP. (you could, but you would have to write more code to look at a paste, see if its a full valid IP, and then fill in each of the 4 textboxes)
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  7. #7
    Junior Member
    Join Date
    Dec 2006
    Posts
    22

    Re: IP Textbox User Control

    I know thats the way the windows one acts but, it would be useful to copy and paste details as well as having the "." and the backspace function

    I have made some adjustments to the project feel free to take a look

    Attached Files Attached Files

  8. #8
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,491

    Re: IP Textbox User Control

    Very nice indeed.

    Can I give a suggestion ( use it / don't use it )

    Why not make it so that you cannot enter 0 0 0 0 or 255 255 255 255 which an IP address cannot be. ¿
    VB.NET MVP 2008 - Present

  9. #9
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,273

    Re: IP Textbox User Control

    Quote Originally Posted by HanneSThEGreaT
    Very nice indeed.

    Can I give a suggestion ( use it / don't use it )

    Why not make it so that you cannot enter 0 0 0 0 or 255 255 255 255 which an IP address cannot be.
    Actually in Windows when it's obtaining an ip address or you use 'IpConfig /Release' The system's IP is '0.0.0.0' and 255.255.255.255 is a valid ip, it's just not one you see

  10. #10
    Junior Member
    Join Date
    Dec 2006
    Posts
    22

    Thumbs up Re: IP Textbox User Control

    Thanks guys for the good suggestions.

    I think its really up to the user of the this feature as to whether they have some kind of validation on the values.

    Cheers

  11. #11
    Member
    Join Date
    Jan 2000
    Location
    IL
    Posts
    39

    Re: IP Textbox User Control

    Ok, assuming I'm an idiot, how do I add this to my program?
    I used to work in vb 5.0, but I'm trying to work more in Visual Studio 2005's Visual Basic.

  12. #12

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: IP Textbox User Control

    which version of Visual Studio?
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  13. #13
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Re: IP Textbox User Control

    One more thing. How you add the functionality so that when the user presses ENTER it will run some sub/function?
    ManagePC - the all-in-one PC management and inventory tool

  14. #14
    New Member
    Join Date
    Jul 2012
    Posts
    1

    Re: IP Textbox User Control

    I have added this sub as a new private sub, so every time you type Enter the current textbox transfers you to the next one.

    vb Code:
    1. Private Sub txtIP_KeyDown(ByVal sender As System.Object, ByVal e As KeyEventArgs) Handles txtIP1.KeyDown, txtIP2.KeyDown, txtIP3.KeyDown, txtIP4.KeyDown
    2.         Dim txtBox As TextBox = DirectCast(sender, TextBox)
    3.         If e.KeyCode = Keys.Enter Then
    4.             Me.SelectNextControl(txtBox, True, True, False, False)
    5.         End If
    6.     End Sub

  15. #15
    New Member
    Join Date
    Nov 2012
    Posts
    2

    Re: IP Textbox User Control

    Thanks very much for this component! It was very useful to control any input ip entry.
    I'm glad to meet people that makes our lives easy

    Thanks again kleinma

  16. #16
    New Member
    Join Date
    Apr 2013
    Posts
    1

    Thumbs up Re: IP Textbox User Control

    Hi!

    Just stopping in to say i like the custom control!

    I know this is an old thread, but i was wondering how can you change the default values on this, i would like to see all blanks instead of 255.255.255.255

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width