|
|
プログラム例 |
'変数宣言
Dim x As Single
Dim y As Single
Dim z As Single
'Private Sub Command1_Click()
'実行ボタンで変更する場合
'If Option1.Value = True Then
'Text1.ForeColor = vbBlack
'End If
'If Option2.Value = True Then
'Text1.ForeColor = vbRed
'End If
Private Sub Check1_Click()
'ボルド(太字)
If Check1.Value = 1 Then
Text1.Font.Bold = True
Else
Check1.Value = 0
Text1.Font.Bold = False
End If
Text1.SetFocus
End Sub
Private Sub Check2_Click()
'イタリック
If Check2.Value = 1 Then
Text1.Font.Italic = True
Else
Check2.Value = 0
Text1.Font.Italic = False
End If
Text1.SetFocus
End Sub
Private Sub Check3_Click()
'アンダーライン
If Check3.Value = 1 Then
Text1.Font.Underline = True
Else
Check2.Value = 0
Text1.Font.Underline = False
End If
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Static flag As Boolean
If flag = False Then
Timer1.Interval = 1000
Command2.Caption = "タイマー停止"
Else
Timer1.Interval = 0
Command2.Caption = "タイマー開始"
End If
flag = Not flag
End Sub
'実行ボタンを使用する場合
'If Option3.Value = True Then
'Text1.ForeColor = vbBlue
'End If
'If Option4.Value = True Then
'Text1.ForeColor = vbYellow
'End If
'If Option5.Value = True Then
'Text1.ForeColor = vbGreen
'End If
'If Option6.Value = True Then
'Text1.ForeColor = QBColor(8)
'End If
'Text1.SetFocus
'End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Option1.Value = True
Command1.Enabled = False
End Sub
'以下は色に関するコーディング
Private Sub Option1_Click()
If Option1.Value = True Then
Text1.ForeColor = vbBlack
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
Text1.ForeColor = vbRed
End If
Text1.SetFocus
End Sub
Private Sub Option3_Click()
If Option3.Value = True Then
Text1.ForeColor = vbBlue
End If
Text1.SetFocus
End Sub
Private Sub Option4_Click()
If Option4.Value = True Then
Text1.ForeColor = vbYellow
End If
Text1.SetFocus
End Sub
Private Sub Option5_Click()
If Option5.Value = True Then
Text1.ForeColor = vbGreen
End If
Text1.SetFocus
End Sub
Private Sub Option6_Click()
If Option6.Value = True Then
Text1.ForeColor = QBColor(8)
End If
Text1.SetFocus
End Sub
'テキストチェンジイベント
Private Sub Text1_Change()
If Text1.Text = "" Then
Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
'ランダムで色やフォントの種類を変更する
Randomize
Text1.ForeColor = QBColor(Int(Rnd * 16))
x = Int(Rnd * 2)
y = Int(Rnd * 2)
z = Int(Rnd * 2)
Text1.Font.Bold = CBool(x)
Text1.Font.Italic = CBool(y)
Text1.Font.Underline = CBool(z)
End Sub