【问题标题】:Conversion from string to integer error in 3.5 from 4.0 .NET Framework从 4.0 .NET Framework 在 3.5 中从字符串转换为整数错误
【发布时间】:2014-04-14 11:15:57
【问题描述】:

当我尝试将 .NET Framework 更改为 4.0 到 3.5 时,我遇到了关于 .NET Framework 的问题。该代码在 4.0 中完美运行,但是当我尝试将其更改为 3.5 时,它给了我一个错误 Conversion from string to integer。那么如何解决这个问题呢?以下是我的代码:

  Dim counter As Integer
  ts = TargetDT.Subtract(DateTime.Now)

  If ts.TotalMilliseconds > 0 Then
  Me.timer.Text = ts.ToString("mm\:ss") 'I get the error from here
  ElseIf ts.TotalMilliseconds < 0 Then

  Timer1.Interval = 500
  CountDownFrom = TimeSpan.FromMinutes(0.5)
  TargetDT = DateTime.Now.Add(CountDownFrom)
  Me.timer.Text = ts.ToString("mm\:ss")

  If Me.timer.Text = "00:00" Then

  counter = counter + 1
  If counter = 1 Then
  saban()
  End If

  End If

 End If

【问题讨论】:

  • 你应该包括上面sn-p中使用的变量的声明,尤其是timer和ts

标签: .net vb.net time .net-4.0 .net-3.5


【解决方案1】:

从该行中删除反斜杠:

Me.timer.Text = ts.ToString("mm\:ss")

实现它

Me.timer.Text = ts.ToString("mm:ss")

【讨论】:

  • Me.Timer 是表单上的 Timer 对象吗?如果是这样,您应该阅读Timer object 的文档。如果不是,那它是什么物体?
猜你喜欢
  • 2013-03-06
  • 1970-01-01
  • 2016-06-08
  • 1970-01-01
  • 1970-01-01
  • 2012-10-08
  • 2015-07-04
  • 1970-01-01
  • 2014-09-19
相关资源
最近更新 更多