• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Wisock Refresh IP?

Hello... I have Wisock report the IP address of the computer to Label1.caption on a timer event.
If the IP address changes (for instance from 127.0.0.1, which is what it is when i am not connected to the internet
to 192.168.0.102, which is what it is when I am connected to the network)... The Wisock component still reports my
address as 127.0.0.1....what is wrong??? here is my code:


Public Sub Timer1_Timer()

Label1.Caption = Winsock1.LocalIP

End Sub
0
udontlikethisstuff
Asked:
udontlikethisstuff
  • 2
  • 2
1 Solution
 
ShauliCommented:
What is your timer interval? and is it enabled?

S
0
 
udontlikethisstuffAuthor Commented:
it is enabled.. i tested it with a msgbox command... every forty seconds it would display the same IP 127.0.0.1 (Unless I connected to the internet then ran the program)
0
 
learning_t0_pr0gramCommented:
try making it a control array with an index of 0 and doing it like this:

Private Sub Timer1_Timer()
Load Winsock1(1)
Label1.Caption = Winsock1(1).LocalIP
Unload Winsock1(1)
End Sub
0
 
learning_t0_pr0gramCommented:
oh.. and the reason this works is because winsock gets ur ip when it is loaded, so without it, when u open ur program it gets the ip and stores it... but when u load a new one, it gets a new ip each time it is loaded...
0
 
udontlikethisstuffAuthor Commented:
Works Great! thanks a lot!...
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now