VBA - 版本系统

时间:2013-06-17 20:24:29

标签: vba

我有一个visual basic app,我的主机中有一个名为version.txt的文件。

我想将它连接到我的vba应用程序,每当我更改用version.txt编写的数字时,该应用程序都会警告用户下载该应用程序的较新版本。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

假设Excel。常量保留在您的应用中,并且Version.txt中的值会发生变化。

Public Const dVERSION As Double = 6.2

Public Function IsCurrentVersion() As Boolean

    Dim sFile As String
    Dim lFile As Long
    Dim dVer As Double

    sFile = ThisWorkbook.Path & Application.PathSeparator & "Version.txt"
    lFile = FreeFile

    Open sFile For Input As lFile
    Input #lFile, dVer
    Close lFile

    IsCurrentVersion = dVer <= dVERSION

End Function