March 5, 2021
Hot Topics:

Customising Your Setup - Part 1

  • By Dax Pandhi
  • Send Email »
  • More Articles »

NetCheck will ask the user if he wants to check if a newer version is available. If he says yes, the Internet Transfer Control will check for a newer version and report back.

In frmSetup1, add an Internet Transfer Control Inet1. Then, go to code view and add this code:

Public Sub NetCheck()On Error Go To ErrUpdate ' Err HandlingDim intMyVersion As IntegerDim b() As ByteDim intRemoteVer As IntegerDim strRemoteVer As StringDim iCheck As Integer' Be polite and ask the user!ICheck = MsgBox("Do you want to check if a never version _         is available on the web?" & _"If yes, then connect to the net and press YES.", _vbYesNo + vbQuestion, "New Version Available")If  iCheck = vbNo Then Exit Sub' If user says no, exit sub' If yes, then open the file for reading!B() = Inet1.OpenURL("http://www.mysite.com/myfile.dat", 1)IntMyVersion = 45 ' Add your version hereStrRemoteVer = ""For t = 0 to Ubound(b)StrRemoteVer = strRemoteVer + Chr(b(t))Next' Check the infointRemoteVer = intMyVersionIf intRemoteVer > intMyVersion Then' Inform the user!MsgBox "A newer version of this software is available at www.mysite.com"ElseMsgBox "You have the latest version available."End IfErrUpdate:' Nothing hereEnd Sub

Explanation of NetCheck

The Inet control loads myfile.dat, a text file with just a version number. Then after loading it into memory, it checks whether the running software's version (intMyVersion) is smaller than the one on the Net (intRemoteVer). If it is, it prompts the user.

NOTE: You have to set the intRemoteVer to the current software version (by changing the myfile.dat value)

To make it easier, make sure both intMyVersion and intRemoteVer are only 1 or 2 digit integers. For example, 1 or 10 or 11, or something like that.

  • After ShowWelcomeForm in frmSetup1's Form_Load(), add this code:
Call NetCheck

Page 7 of 9

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date