Events Private Sub Form_Load() Load Close Unload Private Sub Form_Unload(Cancel As Integer) Cancel=True Cancel * Show Activate SetFocus Focus Deactivate SetFocus GotFocus CommandButton LostFocus Resize System event Paint Label KeyBoard KeyUp DragDrop KeyDown F..F Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbkeyf Then Print "F" ' F Shift User event KeyCode
F..F Private Sub Form_KeyPress(KeyAscii As Integer) v = Chr(KeyAscii) If v = "c" Then Form.Cls Asc AsciiCode AsciiCode KeyPress Chr AsciiCode User event Click DblClick MouseMove Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) MouseUp MouseDown Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = Then Print "Left" ElseIf Button = Then Print "Right" End If if If condition Then [statements] [Else elsestatements] If condition Then [statements] [ElseIf condition-n Then [elseifstatements]... [Else [elsestatements]] End If
Middle Bits of Button Right Left Value (left) (right) 3 (left and right) 4 (middle) Alt Bits of Shift Ctrl Shift Statements Beep : End Exit Sub Randomize Module File Form_Load Function Rnd Rnd[(number)] 3
Print Label Control خصائص شريط الطباعة Label's Properties Name, Backcolor, Top, Left, Height, Width, Tag, MousePointer, MouseIcon, Enabled, Visible, RightToLeft, Font, FontName, FontBold, FontItalic, FontStrikethru, and FontUnderline Label.FontBold=True (set FontBold to True) Label.FontBold=False (reset FontBold to False) Label.FontBold= Not Label.FontBold (toggle FontBold) Caption Label.caption="no" Label.caption=5 (Label.caption=Label.caption+ ) Label.caption="no="+str(x) where x=3, str to convert integer no. to string Label.caption="" 'null caption no 5 no=3 3 4 5 Label.Caption = "Book" + Chr() + "Chair" + Chr() + "CopyBook" Label.Caption = "Book" + vbcrlf + "Chair" + vbcrlf + "CopyBook" Chr(3) Chr() Chr() vbcrlf Chr() Chr(3) 'multiple lines (where autosize property=true and WordWrap=True) Chr() 4
Alignment Alignment Setting Description vbleftjustify (Default) Text is left-aligned. vbrightjustify Text is right-aligned. vbcenter Text is centered. AutoSize True False BorderStyle BackColor BackStyle (Text Box BackStyle Description Transparent background color and any graphics are visible behind the control. (Default) Opaque the control's BackColor property setting fills the control and obscures any color or graphics behind it. Appearance DragIcon Drag DragMode 5
Constant Setting Description vbmanual (Default) Manual requires using the Drag method to initiate a drag-and-drop operation on the source control. vbautomatic Automatic clicking the source control automatically initiates a drag-and-drop operation. OLE container controls are automatically dragged only when they don't have the focus. ToolTipText AutoSize object.wordwrap [= boolean] True WordWrap The settings for boolean are: Setting True False Description The text wraps; the Label control expands or contracts vertically to fit the text and the size of the font. The horizontal size doesn't change. (Default) The text doesn't wrap; the Label expands or contracts horizontally to fit the length of the text and vertically to fit the size of the font and the number of lines. Tab Tab DataField & DataSource TabIndex Index : Events Click, DblClick, MouseDown, MouseUp, MouseMove, DragDrop events. Change Caption Move, Refresh, and Zorder Methods. Object.Zorder position : Methods Zorder 6
Position Label.Zorder ' Label.Zorder ' Label.Zorder ' Comment (single quotation mark) ' Rem Ali Muna Paste Copy Label() Label Label() Yes Label() index index index Private Sub Label_Click(Index As Integer) Label(Index).Caption = Index DragDrop Source if index 7
DragIcon DragDrop Automatic DragMode= Private Sub Label4_DragDrop(Source As Control, X As Single, Y As Single) Label4.BackColor = Source.BackColor Source.Visible = False Zorder 8
Project properties Object Property Setting Form Name Caption Form Label Label Name Label Caption Welcome Alignment الكتابت في الىسط AutoSize يصبح الشزيط بحجم الكلمت True BackColor اخضز BackStyle حتى يأخذ لىن خلفيت مه BackColor ثالثي األبعاد Appearance كلمت تظهز تحته عىدما وؤشز عليه بالماوس ToolTipText Test WordWrap لضبط الكلمت True Label() Name Index Label Label() Name Index Label Label() Name Label Label3 Label4 Poject code Index Name BackColor BackStyle DragMode DragIcon Name BackColor BackStyle Private Sub Form_Load() Label.Caption = "Ali" + Chr() + "Muna" Private Sub Label_Click() Label.FontBold = Not Label.FontBold Private Sub Label_Click(Index As Integer) Label(Index).Caption = Index Private Sub Label3_Click() Label3.ZOrder 9 Label3 احمز 'Automatic صىرة Label4 اسرق
Private Sub Label4_DragDrop(Source As Control, X As Single, Y As Single) Label4.BackColor = Source.BackColor Source.Visible = False