質問編集履歴

5

画像の挿入

2022/05/23 11:12

投稿

0987kjhfas
0987kjhfas

スコア3

test CHANGED
File without changes
test CHANGED
@@ -107,3 +107,4 @@
107
107
  bCount = False
108
108
  End Sub
109
109
  ```
110
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-05-23/58dab947-96ac-4720-8394-f02299ce1d97.png)

4

コードの修正

2022/05/23 04:29

投稿

0987kjhfas
0987kjhfas

スコア3

test CHANGED
File without changes
test CHANGED
@@ -96,7 +96,7 @@
96
96
  End If
97
97
 
98
98
  Label1.Caption = strMin & strSec
99
- ActivePresentation.Slides(2).Caption = strMin & strSec
99
+ ActivePresentation.Slides(2).Label1.Caption = strMin & strSec
100
100
  strTmp = strMin & strSec
101
101
  sPrevious = sCurrent
102
102
  End If

3

コードの修正

2022/05/23 04:16

投稿

0987kjhfas
0987kjhfas

スコア3

test CHANGED
File without changes
test CHANGED
@@ -96,7 +96,7 @@
96
96
  End If
97
97
 
98
98
  Label1.Caption = strMin & strSec
99
- _**ActivePresentation.Slides(2).Caption = strMin & strSec**_
99
+ ActivePresentation.Slides(2).Caption = strMin & strSec
100
100
  strTmp = strMin & strSec
101
101
  sPrevious = sCurrent
102
102
  End If

2

コードの修正

2022/05/23 04:15

投稿

0987kjhfas
0987kjhfas

スコア3

test CHANGED
File without changes
test CHANGED
@@ -96,7 +96,7 @@
96
96
  End If
97
97
 
98
98
  Label1.Caption = strMin & strSec
99
- ActivePresentation.Slides(2).Caption = strMin & strSec
99
+ _**ActivePresentation.Slides(2).Caption = strMin & strSec**_
100
100
  strTmp = strMin & strSec
101
101
  sPrevious = sCurrent
102
102
  End If

1

コードの追加

2022/05/23 04:14

投稿

0987kjhfas
0987kjhfas

スコア3

test CHANGED
File without changes
test CHANGED
@@ -8,3 +8,102 @@
8
8
  ```VBA
9
9
  slide(2).label1.Caption = "サンプル"
10
10
  ```
11
+ ```VBA
12
+ Option Explicit
13
+
14
+ 'スタートボタン押下時のTimer()関数の戻り値
15
+ Dim sStart As Single
16
+ '現在時刻のTimer()関数の戻り値
17
+ Dim sCurrent As Single
18
+ '前回表示を更新した自国のTimer()関数の戻り値
19
+ Dim sPrevious As Single
20
+ 'True:カウントアップ false:停止
21
+ Dim bCount As Boolean
22
+ '時間
23
+ Dim iHour As Integer
24
+ '分
25
+ Dim iMin As Integer
26
+ '秒
27
+ Dim iSec As Integer
28
+ Dim strTmp As String
29
+
30
+ 'スライドショーでページが切り替わった時に実行
31
+ Public Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
32
+ 'スライドショー一枚目に切り替えたとき0秒を表示
33
+ If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex = 1 Then
34
+ 'Label1.Caption = "00:00"
35
+ Label1.Caption = strTmp
36
+ End If
37
+ End Sub
38
+ 'スライドショーが終了時に実行
39
+ Public Sub OnSlideShowTerminate(ByVal Wn As SlideShowWindow)
40
+ 'タイマーの更新を終了
41
+ bCount = False
42
+ End Sub
43
+
44
+ Private Sub StartButton_Click()
45
+
46
+ bCount = True
47
+
48
+ 'sStartに現在の時刻を秒数にしたものを代入
49
+ sStart = Timer()
50
+
51
+ 'Lbel1にsStartを表示
52
+ 'CStr 関数は、数値や日付などを文字列型 (String) に変換
53
+ Label1.Caption = "00:00"
54
+
55
+ '更新時刻を記録
56
+ sPrevious = sStart
57
+
58
+ 'bCountがtrueの間、タイマーを更新。ストップボタンが押されるとbCountがfalseになりタイマーが止まる
59
+ Do While (bCount = True)
60
+ 'sCurrentに現在時刻を代入
61
+ sCurrent = Timer()
62
+
63
+ If (sCurrent - sPrevious) >= 1 Then
64
+
65
+ '経過秒を表す整数
66
+ Dim iElapsedSec As Integer
67
+ iElapsedSec = CInt(sCurrent - sStart)
68
+
69
+ iHour = iElapsedSec \ 3600
70
+ iMin = (iElapsedSec Mod 3600) \ 60
71
+ iSec = (iElapsedSec Mod 3600) Mod 60
72
+
73
+ Dim strHour As String
74
+ Dim strMin As String
75
+ Dim strSec As String
76
+
77
+ '時間が二桁以外の場合ゼロを足す
78
+ If iHour >= 10 Then
79
+ strHour = CStr(iHour) & ":"
80
+ Else
81
+ strHour = "0" & CStr(iHour) & ":"
82
+ End If
83
+
84
+ '分が二桁以外の場合ゼロを足す
85
+ If iMin >= 10 Then
86
+ strMin = CStr(iMin) & ":"
87
+ Else
88
+ strMin = "0" & CStr(iMin) & ":"
89
+ End If
90
+
91
+ '秒が二桁以外の場合ゼロを足す
92
+ If iSec >= 10 Then
93
+ strSec = CStr(iSec)
94
+ Else
95
+ strSec = "0" & CStr(iSec)
96
+ End If
97
+
98
+ Label1.Caption = strMin & strSec
99
+ ActivePresentation.Slides(2).Caption = strMin & strSec
100
+ strTmp = strMin & strSec
101
+ sPrevious = sCurrent
102
+ End If
103
+ DoEvents
104
+ Loop
105
+ End Sub
106
+ Private Sub StopButton_Click()
107
+ bCount = False
108
+ End Sub
109
+ ```