|
-
Nov 6th, 2005, 12:06 AM
#1
Thread Starter
Fanatic Member
Object variable not set
VB Code:
Public Type sockaddr_in
sin_family As Integer
sin_port As Integer
sin_addr As Long
sin_zero(1 To 8) As Byte
End Type
Dim addr As sockaddr_in
Dim ip As String
[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
-
Nov 6th, 2005, 12:33 AM
#2
Re: Object variable not set
try:
VB Code:
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.
-
Nov 6th, 2005, 12:37 AM
#3
Thread Starter
Fanatic Member
Re: Object variable not set
When doing this:
VB Code:
Dim ip As String
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:
Dim ip As Object
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
-
Nov 6th, 2005, 12:40 AM
#4
Frenzied Member
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::

-
Nov 6th, 2005, 12:45 AM
#5
Thread Starter
Fanatic Member
Re: Object variable not set
inet_ntoa() returns a Long
VB Code:
Dim ip As Long
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
-
Nov 6th, 2005, 02:47 AM
#6
Re: Object variable not set
VB Code:
Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source _
As Any, ByVal length As Long)
Public Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal lpString As Any) As Long
Dim ip as Long
Dim ipString as string
ip = inet_ntoa(Addr.sin_addr)
' Copy the result into a string variable.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|