2017-12-04 2 views
-1

Visual Studio VBSでこのコードのヘルプが必要ですが、テキストにすべての変数を出力する方法がわかりません。 jmcilhinneyにより示唆されるようにここでVBSタイマークロック - 出力ラベル

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick 
    Dim timer 
    Dim timer2 
    Dim timer3 
    Dim finaltimer 
    timer = (sec.Text + 1) 
    timer = Format(timer, "00") 
    If timer = 60 Then 
     timer = 0 
     timer2 = (min.Text + 1) 
     timer2 = Format(timer2, "00") 
     If timer2 = 60 Then 
      timer2 = 0 
      timer3 = (hour.Text + 1) 
      timer3 = Format(timer3, "00") 
     End If 
    End If 
    finaltimer = timer & ":" & timer2 & ":" & timer3 
    sec.Text = finaltimer 
End Sub 
+0

'sec.Text'はどのように行う、'「午前1時35分59秒」 'のようなものであることが予想される場合あなたはそれに1を加えることを期待していますか? – YowE3K

+0

ありがとう、私は今これを見ました... 私はちょっと気分が悪いと感じています –

+0

ちょうど開始時間(「タイマー」が始まったとき)を把握してから、私はVBAに慣れているので、これはVB.Netで必ずしも同じではありません) 'finaltimer = Format(Now() - startTime、" hh:mm:ss ")' – YowE3K

答えて

0

はストップウォッチアプローチの簡単な例です:

Private SW As New Stopwatch 

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
    SW.Start() 
    Timer1.Start() 
End Sub 

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick 
    Dim ts As TimeSpan = SW.Elapsed 
    Label1.Text = ts.ToString("hh\:mm\:ss") 
End Sub 
関連する問題