.


:




:

































 

 

 

 


TextBox




10

VBA. . . .

: .

Excel:

ApplicationWorkBoorWorkSheetChart

. Excel . VBA. VBAProject. 1 . . , , , VBA .

2, 1 , .

. .

Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel As Boolean)......End Sub

, . .

Private Sub Workbook_SheetActivate(ByVal Sh As Object) MsgBox (Sh.Name)End Sub

.

. VBA, . Microsoft Excel , , UserForm.

(), , . Caption, . . . . "", "". Caption. .

. . . Test.

Private Sub CommandButton1_Click() MsgBox ("Test Button Press")End Sub

:

Private Sub CommandButton2_Click() Unload MeEnd Sub

Unload Me . . FormsRun . .

Sub FormsRun() UserForm1.ShowEnd Sub

. . Test, , , .

, .

.

. , . , , .

Private Sub CommandButton1_Click() UserForm1.BackColor = RGB(255, 10, 10)End Sub

, .

Sub test() Load UserForm1 UserForm1.Show Unload UserForm1End Sub

, , VBA . . :

- inherent

- custom

.

ActiveX, . OCX . .

" " , . , OK.

.

. .

(KeyDown, KeyUp, KeyPress)

:

KeyDownKeyUpKeyPress

. KeyPress , ASCII . . :

Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) End Sub

TextBox, :

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) End Sub

. , , , . KeyUp KeyDown Ctrl+Del, KeyPress . . :

. :

Private Sub Test() Dim ctrl As Control Dim bool As Boolean bool = True For Each ctrl In Controls If TypeName(ctrl) = "TextBox" Then If ctrl.Text = "" Then bool = False End If End If Next ctrl UserForm1.CommandButton1.Enabled = boolEnd Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call TestEnd Sub Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call TestEnd Sub Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call TestEnd Sub

TextBox

, . :

MaxLengthPasswordCharLocked

MaxLength , . , . PasswordChar (*). , , . Locked . :

 

. , . PasswordChar , .

 

.

Locked , , .

Private Sub CommandButton1_Click() TextBox3.Locked = FalseEnd Sub

MaxLength:

Private Sub CommandButton1_Click() TextBox3.Locked = FalseEnd Sub

PasswordChar:

Private Sub CommandButton1_Click() TextBox2.PasswordChar = "x"End Sub

.





:


: 2016-09-03; !; : 1562 |


:

:

, ; , .
==> ...

1741 - | 1504 -


© 2015-2024 lektsii.org - -

: 0.012 .