【问题标题】:simple counter to track form ussage?跟踪表单使用情况的简单计数器?
【发布时间】:2011-04-19 12:17:35
【问题描述】:

我想知道如何从文本文件中读取一个数字,然后将该数字乘以一并将其写回原始文本文件,我正在尝试制作一个计数器来跟踪我的次数表格被执行。然后,这些信息将用于确定我的应用在我们公司中的成功与否。

【问题讨论】:

  • 您不需要任何代码。乘以一不会改变任何东西的价值。除了你的问题太模糊。你到底有什么问题?读取文件?写一个?这些主题都包含在教程和文档中,可通过网络搜索轻松访问。
  • 旁注:如果你真的想要乘以一,你应该用*替换我例子中的+;)

标签: vb.net add counter


【解决方案1】:

你可以用这个:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-13
    • 2018-11-22
    • 1970-01-01
    • 2011-09-30
    • 2014-01-27
    • 2012-04-01
    相关资源
    最近更新 更多