By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

Is this possible?

P: 34
I have a program i made, compiled as an .exe; though each user needs to enter their IP the first time it's opened to have it store their IP.

Then i need it to be possible for them to change it when their IP changes.

How can i do this without changing the code in every project and compiling it separately?
Sep 14 '07 #1
Share this Question
Share on Google+
2 Replies


VBPhilly
P: 95
I have a program i made, compiled as an .exe; though each user needs to enter their IP the first time it's opened to have it store their IP.

Then i need it to be possible for them to change it when their IP changes.

How can i do this without changing the code in every project and compiling it separately?
how can you persist such settings?
or, how can you detect when IP changes?

for persistence (storing the value), you can use the registry:

Expand|Select|Wrap|Line Numbers
  1.    SaveSetting "myapplicationname", "mysettings", "myip", "127.0.0.1"
  2.    GetSetting "myapplicationname", "mysettings", "myip", ""
  3.  
for checking ip, you'll need something like a winsock control.
make a reference to it in your project (it will be part of components).
then, drop an instance of it on your form.
to get the local ip, simple:

Expand|Select|Wrap|Line Numbers
  1. msgbox winsock1.localip 
  2.  
Sep 14 '07 #2

kadghar
Expert 100+
P: 1,295
I have a program i made, compiled as an .exe; though each user needs to enter their IP the first time it's opened to have it store their IP.

Then i need it to be possible for them to change it when their IP changes.

How can i do this without changing the code in every project and compiling it separately?
I dont think i understood you quite well, but you have two options, in the code, instead of writing the IP use a String variable, then just put an inputbox where they write their IP each time they start the program. If each user want to save a defoult IP, save it into another archive, the easiest way will be a TXT file.

Something like this will read the file and save its first line into the string called defoultIP or do nothing if the file doesnt exist

Expand|Select|Wrap|Line Numbers
  1. Dim defoultIP as string
  2. Dim myIP as string
  3. on error resume next
  4. open "c:\myIPs.txt" for input as #1
  5. input #1, defoultip
  6. close #1
now here we'll ask for an IP adress showing the defoult as the one we've already read. In case we use a different one, it'll be saved as de defoult one.
If there wasnt a defoult one, it'll show the empty string.

Expand|Select|Wrap|Line Numbers
  1. myip = inputbox("Please write your IP adress", "IP adress", defoultip)
  2. if myip <> defoultip then
  3.     open "c:\myIPs.txt" for output As #1
  4.     print #1, myip
  5.     close #1
  6. end if
and now you have the ip stored in myIP

HTH
Sep 14 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.