テキストボックスの使い方:Excel VBA入門 |
| スポンサードリンク | |
| IMEModeプロパティ | MaxLengthプロパティ | MultiLineプロパティ | ScrollBarsプロパティ |
| PasswordCharプロパティ | その他のプロパティ | ||
| テキストボックスの値をセルに入力する | セルの値をテキストボックスに表示 | ||
| テキストボックスの数値を桁区切りにする | |||
| 値 | 定数 | |
| 0 | fmIMEModeNoControl | 変更しない(規定値) |
| 1 | fmIMEModeOn | IMEをONにする |
| 2 | fmIMEModeOff | IMEをOFFにする |
| 3 | fmIMEModeDisable | IMEを無効にする |
| 4 | fmIMEModeHiragana | ひらがなモードにする |
| 5 | fmIMEModeKatakana | 全角カタカナモードにする |
| 6 | fmIMEModeKatakanaHalf | 半角カタカナモードにする |
| 7 | fmIMEModeAlphaFull | 全角英数モードにする |
| 8 | fmIMEModeAlpha | 半角英数モードにする |
| Private Sub UserForm_Initialize() UserForm1.Caption = "商品名の入力" With TextBox1 .Value = "" .IMEMode = fmIMEModeKatakana .SetFocus End With End Sub |
| Private Sub UserForm_Initialize() UserForm1.Caption = "商品名の入力" With TextBox1 .Value = "" .IMEMode = fmIMEModeKatakana .MaxLength = 5 .SetFocus End With End Sub |
| Private Sub UserForm_Initialize() UserForm1.Caption = "商品名の入力" With TextBox1 .Value = "" .MaxLength = 5 .SetFocus .AutoTab = True End With End Sub |
| Private Sub UserForm_Initialize() UserForm1.Caption = "商品名の入力" With TextBox1 .Value = "" .MultiLine = True .SetFocus End With End Sub |
| Private Sub UserForm_Initialize() UserForm1.Caption = "商品名の入力" With TextBox1 .Value = "" .MultiLine = True .EnterKeyBehavior = True .SetFocus End With End Sub |
| 値 | 定数 | |
| 0 | fmScrollBarsNone | スクロールバーを表示しない |
| 1 | fmScrollBarsHorizontal | 水平スクロールバーを表示する |
| 2 | fmScrollBarsVertical | 垂直スクロールバーを表示する |
| 3 | fmScrollBarsBoth | 水平・垂直スクロールバーを表示する |
| Private Sub UserForm_Initialize() UserForm1.Caption = "商品名の入力" With TextBox1 .Value = "" .MultiLine = True .EnterKeyBehavior = True .ScrollBars = fmScrollBarsVertical .SetFocus End With End Sub |
| Private Sub UserForm_Initialize() With TextBox1 .Value = "" .PasswordChar = "*" .SetFocus End With End Sub |
| 定数 | 値 | 内容 |
| fmBackStyleTransparent | 0 | 背景を透明にします。 |
| FmBackStyleOpaque | 1 | 背景を不透明にします (既定値) |
| 定数 | 値 | 内容 |
| fmBorderStyleNone | 0 | 境界線を表示しない。 |
| fmBorderStyleSingle | 1 | 実線の境界線 (既定値) |
| Private Sub CommandButton1_Click() Dim LastRow As Long LastRow = Range("A" & Rows.Count).End(xlUp).Row Range("A" & LastRow + 1).Value = TextBox1.Value TextBox1.Value = "" End Sub Private Sub CommandButton2_Click() Unload Me End Sub Private Sub UserForm_Initialize() With TextBox1 .Value = "" .SetFocus End With End Sub |
| Sub test() Load UserForm1 UserForm1.Show vbModeless End Sub |
| Private Sub CommandButton1_Click() ActiveCell.Value = TextBox1.Value TextBox1.Value = "" End Sub Private Sub TextBox1_Change() If TextBox1.Value = "" Then Exit Sub TextBox1.Text = Format(TextBox1.Value, "#,##0") End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then KeyAscii = 0 End Sub |
| Private Sub TextBox1_Change() If TextBox1.Value = "" Then Exit Sub TextBox1.TextAlign = fmTextAlignRight TextBox1.Text = Format(TextBox1.Value, "#,##0") End Sub |
| 定数 | 値 | 内容 |
| fmTextAlignLeft | 1 | 文字列の先頭の文字を編集領域の左端に合わせて表示します (既定値)。 |
| fmTextAlignCenter | 2 | 中央揃えで文字列を表示します。 |
| fmTextAlignRight | 3 | 文字列の最後の文字を編集領域の右端に合わせて表示します。 |
スポンサードリンク
PageViewCounter
Since2006/2/27