开发者

simple counter to track form ussage?

I would like to know how I can read a number from a text file开发者_如何学编程 then multiply that figure by one and write that back to the original text file, I'm trying to make a counter to keep track of how many times my forms are executed. The information will then be used to determine the success of my apps with in our company.


You can use this:

Private Sub Increment()
    Dim Path_To_File As String = "Path to the file"
    Try
        Dim Counter As Integer = CInt(My.Computer.FileSystem.ReadAllText(Path_To_File))
        My.Computer.FileSystem.WriteAllText(Path_To_File, (Counter + 1).ToString(), False)
    Catch Ex As Exception ' Modifiy to catch specific errors if you want
        MessageBox.Show("An error occured: " & Ex.ToString())
    End Try
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜