Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
online text-file maken met versienummer, ernaast ergens de files
in je prog checken of de versie overeenkomt met de online-textfile, zo niet, de files downloaden![]()
dim sVersie as string
sVersie = app.major & "." & app.minor & "." & app.revision
Option Explicit
'API for doenloadtofile
Public Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
'constants
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
'download-fuction
Public Function Downloadfile(sSourceUrl As String, sLocalFile As String) As Boolean
Downloadfile = URLDownloadToFile(0&, sSourceUrl, sLocalFile, BINDF_GETNEWESTVERSION, 0&) = ERROR_SUCCESS
End Function
Public Function Load(Sourceurl As String, Localfile As String, Placein As TextBox)
'load_n_display
Dim sSourceUrl As String
Dim sLocalFile As String
Dim hfile As Long
If Left(Sourceurl, 3) = "www" Then
Sourceurl = "http://" & Sourceurl
End If
sSourceUrl = Sourceurl
sLocalFile = Localfile
If Downloadfile(sSourceUrl, sLocalFile) Then
hfile = FreeFile
Open sLocalFile For Input As #hfile
Placein.Text = Input$(LOF(hfile), hfile)
Close #hfile
End If
End Function
Load("http://www.JOUSERVER.com/versie.txt", app.path & "\versie.txt", txtVersie)
if txtVersie = sVersie then
msgbox "Deze versie is de nieuwste!"
else
msgbox "Er is een nieuwere versie!"
end if
google, pscode.com?
1.) ik neem aan dat je zelf met kladblok een .txt kan maken met een versie-nummer erin. (bijvoorbeeld 1.0.1) en slat op als versie.txt ofzo. upload het naar een server.
2.) in je programma weet hoe je het versie-nummer kan opslaan in een string
(zo niet: kijk en leer)
Code:dim sVersie as string sVersie = app.major & "." & app.minor & "." & app.revision
3.) maak een nieuwe module (gethtml.bas ofzo?) en paste de volgende code:
Code:Option Explicit 'API for doenloadtofile Public Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long 'constants Private Const ERROR_SUCCESS As Long = 0 Private Const BINDF_GETNEWESTVERSION As Long = &H10 Private Const INTERNET_FLAG_RELOAD As Long = &H80000000 'download-fuction Public Function Downloadfile(sSourceUrl As String, sLocalFile As String) As Boolean Downloadfile = URLDownloadToFile(0&, sSourceUrl, sLocalFile, BINDF_GETNEWESTVERSION, 0&) = ERROR_SUCCESS End Function Public Function Load(Sourceurl As String, Localfile As String, Placein As TextBox) 'load_n_display Dim sSourceUrl As String Dim sLocalFile As String Dim hfile As Long If Left(Sourceurl, 3) = "www" Then Sourceurl = "http://" & Sourceurl End If sSourceUrl = Sourceurl sLocalFile = Localfile If Downloadfile(sSourceUrl, sLocalFile) Then hfile = FreeFile Open sLocalFile For Input As #hfile Placein.Text = Input$(LOF(hfile), hfile) Close #hfile End If End Function
4.) in je programma maak je nu een textbox (bijvoorbeeld txtVersie) en roep je deze code aan als je je versie wilt checken:
(LOAD-functie: de 1e is de link naar je online textbestand, de 2e naar een bepaald pad, de 3e de textbox waarin je het wil laden)Code:Load("http://www.JOUSERVER.com/versie.txt", app.path & "\versie.txt", txtVersie) if txtVersie = sVersie then msgbox "Deze versie is de nieuwste!" else msgbox "Er is een nieuwere versie!" end if
Zoiets dus. De code klopt mischien soms niet, maar is eventjes uitt hoofd.
V.:thumb:
Maar meestal is dat voor vbt6.0![]()
zou je misschien de code willen posten
Nja ik wil je er wel mee helpen, maar post liever niet op internet![]()
hoe zo post je het liever niet?Nja ik wil je er wel mee helpen, maar post liever niet op internet![]()
If Not bgwUpdates.IsBusy Then
bgwUpdates.RunWorkerAsync() 'get update data
Private Sub bgwUpdates_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwUpdates.DoWork
Const fileName As String = "updates.txt" 'set name of txtfile
If My.Computer.Network.IsAvailable Then 'if an internet connection is avaible
Try
My.Computer.Network.DownloadFile(udWanPath & fileName, _
udPcPath & fileName, "", "", False, 50000, True)
Dim contentsStr As String = readFile(udPcPath & fileName, True) 'store file into array
contents = Split(contentsStr, "||")
bgwUpdates.CancelAsync() 'stop bg worker
Catch
If bgwUpdates.IsBusy Then bgwUpdates.CancelAsync() 'stop bg worker
udLoaded = False
End Try
End If
End Sub
Private Sub bgwUpdates_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgwUpdates.RunWorkerCompleted
Dim updateInfo As String() : ReDim updateInfo(UBound(contents) \ 3)
Dim x As Integer, y As Integer = 0
For x = 9 To 18 Step 3 'get relevant data
updateInfo(y) = contents(x)
y += 1
Next
UpdateNotes = ""
For x = 21 To 23 'get update notes
If contents(x) <> "" Then UpdateNotes &= contents(x) & vbNewLine
Next
If UpdateNotes <> "" Then Microsoft.VisualBasic.Left(UpdateNotes, UpdateNotes.Length - 2) 'delete last return
UpdateLocation = updateInfo(0) 'array data to individual strings
LatestDev = updateInfo(1)
LatestDate = updateInfo(2)
LatestStabile = updateInfo(3)
'show elements
udLoaded = True
If udLoaded Then
gBoxUpdates.Visible = True : showUpdateElements() : updatesDefault()
Else
hideUpdateElements() 'hide content
lblLoadingUpd.Text = "Er kan geen verbinding worden gemaakt..."
End If
End Sub
Public Function readFile(ByVal myPath As String) As String
Dim myReader As New System.IO.StreamReader(myPath) 'reader
Dim fullTxt As String = ""
If System.IO.File.Exists(myPath) Then 'only read when file exists
Do While myReader.Peek() <> -1 'read all lines and make one string
fullTxt = fullTxt & myReader.ReadLine() & vbNewLine
Loop
fullTxt = Microsoft.VisualBasic.Left(fullTxt, fullTxt.Length - 2) 'remove last return
End If
Return fullTxt
End Function
Public Function readFile(ByVal myPath As String, _
ByVal toArray As Boolean) As String
If Not toArray Then Return readFile(myPath) : Exit Function
Dim myReader As New System.IO.StreamReader(myPath) 'reader
Dim fullTxtArr As String() : ReDim fullTxtArr(30)
Dim fullTxt As String
Dim x As Integer = 1
If System.IO.File.Exists(myPath) Then 'only read when file exists
Do While myReader.Peek() <> -1 'read all lines and make one string
fullTxtArr(x) = myReader.ReadLine()
x += 1
Loop
End If
fullTxt = Join(fullTxtArr, "||")
Return fullTxt
End Function
Private Sub updatesDefault()
Dim upToDate As String
If frmMain.appVersion = LatestStabile Then
lblVersion.ForeColor = Color.DarkGreen
upToDate = "is up to date"
Else
lblVersion.ForeColor = Color.DarkRed
upToDate = "is veroudert" & Chr(13) & "Download versie " & LatestStabile & " nu!"
End If
lblVersion.Text = "De huidige versie (" & frmMain.appVersion & ") " & upToDate
lblLatestDev.Text = "Laatste versie in ontwikkeling: " & LatestDev & " (" & LatestDate & ")"
linkDlLatest.Text = "Download versie " & LatestStabile
If UpdateNotes <> "" Then MessageBox.Show("Extra info:" & Chr(13) & UpdateNotes)
End Sub
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.