Thursday, November 11, 2010

How to make a VB program saying what times the minute hands of a clock over lap with the hour hands.?

Please do so using a do while loop.How to make a VB program saying what times the minute hands of a clock over lap with the hour hands.?
' In 12 hours the minute hand makes 12 revolutions

' and the hour hand makes 1 revolution in the same direction

'

' so they meet every 12/11 hours

'

Sub ClockHands()

聽Dim i As Long, H As Long, M As Long, S As Long

聽Dim t As Single, seconds As Long

聽Dim tt As String



聽For i = 1 To 11

聽聽t = i * 12 / 11 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ' hours as decimal number

聽聽H = Int(t) ' hours

聽聽seconds = Round((t - H) * 3600)

聽聽M = seconds \ 60聽 聽 聽 聽 聽 聽 聽 聽聽 ' minutes

聽聽S = seconds Mod 60聽 聽 聽 聽 聽 聽 ' seconds

聽聽tt = H %26amp; ';:'; %26amp; M %26amp; ';:'; %26amp; S聽 聽聽 ' compose output

'聽聽(output tt)

聽聽Cells(i, 1) = tt 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ' does it for Excel

聽Next i



End Sub

No comments:

Post a Comment