Results 1 to 10 of 10

Thread: ip/drop down

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    21

    ip/drop down

    Hey guyz,

    i need some help here with 2 things.
    Im making this Novell program so i need help with these..thanks!

    1.) i need to know how to make a text box that will display the users ip address, does ne1 know any simple codes?

    2.) i also need help with making when you click on a button, a drop down box comes up, does ne1 know how to do that either?? please i really need help. Thanks yall


    -Calvin

  2. #2
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: ip/drop down

    Hi llamaboy, I think this is what you need

    To get IP Address
    VB Code:
    1. 'This project requires the following components:
    2. ' - a form (Form1) with a textbox (Text1, Multiline=True)
    3. '   and a command button (Command1)
    4. ' - a module (Module1)
    5.  
    6. 'in Form1:
    7. Private Sub Command1_Click()
    8.     Module1.Start
    9. End Sub
    10.  
    11. 'In Module1:
    12.  
    13. '******************************************************************
    14. 'Created By Verburgh Peter.
    15. ' 07-23-2001
    16. ' [email]verburgh.peter@skynet.be[/email]
    17. '-------------------------------------
    18. 'With this small application , you can detect the IP's installed on your computer,
    19. 'including subnet mask , BroadcastAddr..
    20. '
    21. 'I've wrote this because i've a programm that uses the winsock control, but,
    22. 'if you have multiple ip's  installed on your pc , you could get by using the Listen
    23. ' method the wrong ip ...
    24. 'Because Winsock.Localip => detects the default ip installed on your PC ,
    25. ' and in most of the cases it could be the LAN (nic) not the WAN (nic)
    26. 'So then you have to use the Bind function ,to bind to your right ip..
    27. 'but how do you know & find that ip ?
    28. 'you can find it now by this appl.. it check's in the api.. IP Table..
    29. '******************************************************************
    30.  
    31.  
    32. Const MAX_IP = 5   'To make a buffer... i dont think you have more than 5 ip on your pc..
    33.  
    34. Type IPINFO
    35.     dwAddr As Long   ' IP address
    36.     dwIndex As Long '  interface index
    37.     dwMask As Long ' subnet mask
    38.     dwBCastAddr As Long ' broadcast address
    39.     dwReasmSize  As Long ' assembly size
    40.     unused1 As Integer ' not currently used
    41.     unused2 As Integer '; not currently used
    42. End Type
    43.  
    44. Type MIB_IPADDRTABLE
    45.     dEntrys As Long   'number of entries in the table
    46.     mIPInfo(MAX_IP) As IPINFO  'array of IP address entries
    47. End Type
    48.  
    49. Type IP_Array
    50.     mBuffer As MIB_IPADDRTABLE
    51.     BufferLen As Long
    52. End Type
    53.  
    54. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    55. Public Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
    56. Sub main()
    57.     Form1.Show
    58. End Sub
    59.  
    60. 'converts a Long  to a string
    61. Public Function ConvertAddressToString(longAddr As Long) As String
    62.     Dim myByte(3) As Byte
    63.     Dim Cnt As Long
    64.     CopyMemory myByte(0), longAddr, 4
    65.     For Cnt = 0 To 3
    66.         ConvertAddressToString = ConvertAddressToString + CStr(myByte(Cnt)) + "."
    67.     Next Cnt
    68.     ConvertAddressToString = Left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)
    69. End Function
    70.  
    71. Public Sub Start()
    72.     Dim Ret As Long, Tel As Long
    73.     Dim bBytes() As Byte
    74.     Dim Listing As MIB_IPADDRTABLE
    75.    
    76.     Form1.Text1 = ""
    77.    
    78.     On Error GoTo END1
    79.     GetIpAddrTable ByVal 0&, Ret, True
    80.    
    81.     If Ret <= 0 Then Exit Sub
    82.     ReDim bBytes(0 To Ret - 1) As Byte
    83.     'retrieve the data
    84.     GetIpAddrTable bBytes(0), Ret, False
    85.    
    86.     'Get the first 4 bytes to get the entry's.. ip installed
    87.     CopyMemory Listing.dEntrys, bBytes(0), 4
    88.     'MsgBox "IP's found : " & Listing.dEntrys    => Founded ip installed on your PC..
    89.     Form1.Text1 = Listing.dEntrys & "   IP addresses found on your PC !!" & vbCrLf
    90.     Form1.Text1 = Form1.Text1 & "----------------------------------------" & vbCrLf
    91.     For Tel = 0 To Listing.dEntrys - 1
    92.         'Copy whole structure to Listing..
    93.         ' MsgBox bBytes(tel) & "."
    94.         CopyMemory Listing.mIPInfo(Tel), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len(Listing.mIPInfo(Tel))
    95.         Form1.Text1 = Form1.Text1 & "IP address                   : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr) & vbCrLf
    96.         Form1.Text1 = Form1.Text1 & "IP Subnetmask            : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwMask) & vbCrLf
    97.         Form1.Text1 = Form1.Text1 & "BroadCast IP address  : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwBCastAddr) & vbCrLf
    98.         Form1.Text1 = Form1.Text1 & "**************************************" & vbCrLf
    99.     Next
    100.    
    101.     'MsgBox ConvertAddressToString(Listing.mIPInfo(1).dwAddr)
    102.     Exit Sub
    103.     END1:
    104.     MsgBox "ERROR"
    105. End Sub
    For drop down (I'm assuming you mean right click) menu
    VB Code:
    1. Option Explicit
    2.  
    3.     'For this you need to make a menu in the menu editor with atleast one
    4.     'Sub Menu and call the first mnuFile with index of 0
    5.  
    6.     Private Declare Function LockWindowUpdate Lib "User32" (ByVal hwndLock As Long) As Long
    7.  
    8.  
    9. Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    10.     If Button = vbRightButton Then
    11.            LockWindowUpdate Command1.hWnd
    12.            Command1.Enabled = False
    13.            PopupMenu mnuFile(0)
    14.            LockWindowUpdate 0&
    15.            Command1.Enabled = True
    16.         End If
    17. End Sub
    Last edited by paralinx; Nov 29th, 2005 at 06:58 PM.

  3. #3
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: ip/drop down

    oh one more thing, when you create the drop down menu in the menu editor be sure to set it's visible property to false

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    21

    Re: ip/drop down

    Thanks Thanks U Guyz R Sooo Great!!!

  5. #5
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: ip/drop down

    Your welcome glad to have helped

    If you have gotten your answer then edit your original post and put (resolved) in the title and change the thread icon to the

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    21

    Re: ip/drop down

    hey paralinx,

    uhh c im new to vb kinda, and like i keep gettin this error message, and i dont know how to really resolve it. Im sorry this is kinda late, but would it be possible for you to compile the 2 scripts into a vb file so i could open it and use it for my program, (so it would work fine) you can either reply or email me at nivilca@gmail.com. Thanks Thanks!

    -Calvin

  7. #7
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: ip/drop down

    hey paralinx,

    Want to include an invoice with that????

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    21

    Re: ip/drop down

    ???an invoice???

  9. #9
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: ip/drop down

    lol
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: ip/drop down

    a little too much stuff it grabs?


    I havn't really looked closely at it I got it off the internet...



    sorry if it's bad code
    Last edited by paralinx; Nov 30th, 2005 at 06:33 PM.

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