Results 1 to 6 of 6

Thread: Object variable not set

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Posts
    566

    Object variable not set

    VB Code:
    1. Public Type sockaddr_in
    2.     sin_family       As Integer
    3.     sin_port         As Integer
    4.     sin_addr         As Long
    5.     sin_zero(1 To 8) As Byte
    6. End Type
    7.  
    8. Dim addr As sockaddr_in
    9. Dim ip As String
    10. [b]ip = inet_ntoa(addr.sin_addr)[/b]
    It errors "Object variable or With block variable not set" on the bold line. I researched this on MSDN and it says I have to "Dim something As Object" and "Set someting = ????" for it to work. What must I be doing?

    MSDN article = http://msdn.microsoft.com/library/de...gobjnotset.asp
    if you helped me, consider yourself thanked

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Object variable not set

    try:

    VB Code:
    1. Set ip = inet_ntoa(addr.sin_addr)
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Posts
    566

    Re: Object variable not set

    When doing this:
    VB Code:
    1. Dim ip As String
    2.     Set [b]ip =[/b] inet_ntoa(Addr.sin_addr)
    The error is on the bold line saying "Object required".

    When I do this:
    VB Code:
    1. Dim ip As Object
    2.     Set ip = [b]inet_ntoa[/b](addr.sin_addr)
    It errors on the bold line saying "Type mismatch".
    if you helped me, consider yourself thanked

  4. #4
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Object variable not set

    Well what does inet_ntoa() return?

    You would just have to define "ip" as what ever it returns.

    Type Mismatch in that case means your using the wrong type of variable to store the returned data the function gives to you.
    Last edited by Inuyasha1782; Nov 6th, 2005 at 12:43 AM.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Posts
    566

    Re: Object variable not set

    inet_ntoa() returns a Long
    VB Code:
    1. Dim ip As Long
    2.     Set [b]ip[/b] = inet_ntoa(Addr.sin_addr)
    Error "Object required". It goes back and forth everytime I changed something.

    EDIT: saw you edited your post. how do you think this can be fixed?
    if you helped me, consider yourself thanked

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

    Re: Object variable not set

    VB Code:
    1. Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source _
    2.     As Any, ByVal length As Long)
    3. Public Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal lpString As Any) As Long
    4.  
    5. Dim ip as Long
    6. Dim ipString as string
    7. ip = inet_ntoa(Addr.sin_addr)
    8. ' Copy the result into a string variable.
    9. ipString = Space(lstrlen(ip))
    Last edited by randem; Nov 6th, 2005 at 03:09 AM.

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