|
おはようございます。
結構手抜いて書いてます。
キー操作だけの事で考えました。
クラスとか使っていません。
フォームレイアウトが、こんな場合として書いてあります。
Label1 Label2 Label3
textBox1 textBox5 textBox9
textBox2 textBox6 textBox10
textBox3 textBox7 textBox11
textBox4 textBox8 textBox12
CommandButton1
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 1
End If
End Sub
Private Sub TextBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 1
End If
End Sub
Private Sub TextBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 1
End If
End Sub
Private Sub TextBox4_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 1
End If
End Sub
Private Sub TextBox5_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 2
End If
End Sub
Private Sub TextBox6_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 2
End If
End Sub
Private Sub TextBox7_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 2
End If
End Sub
Private Sub TextBox8_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 2
End If
End Sub
Private Sub TextBox9_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 3
End If
End Sub
Private Sub TextBox10_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 3
End If
End Sub
Private Sub TextBox11_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 3
End If
End Sub
Private Sub TextBox12_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Or KeyCode = 38 Or KeyCode = 40 And Left(ActiveControl.Name, 4) = "Text" Then
LabelFont 3
End If
End Sub
Sub LabelFont(No)
For i = 1 To 3
With Me.Controls("Label" & i)
If i = No Then
.Font.Underline = True
.ForeColor = &HC0&
Else
.Font.Underline = False
.ForeColor = &H80000012
End If
End With
Next
DoEvents
End Sub
Private Sub UserForm_Initialize()
With Label1
.Font.Underline = True
.ForeColor = &HC0&
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
For i = 1 To 3
With Me.Controls("Label" & i)
.Font.Underline = False
.ForeColor = &H80000012
End With
Next
DoEvents
End Sub
|
|