انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Visual Basic controls

Share |
الكلية كلية هندسة المواد     القسم قسم هندسة المعادن     المرحلة 2
أستاذ المادة رفاه ابراهيم جبار       10/03/2019 14:16:25

Visual Basic controls

1. Control properties

• To place a control on a form, two methods can be used:
1. Double click on the control icon in the Toolbox, the control will appear in the middle of the form.
2. Click on the control icon in the Toolbox then click on the desired location on the Form. Drag the mouse diagonally, the control will create on the form.
• To change the position of the control, click on the control and then drag it to a new location.
• To resize the control, click on the control and then resize the pointer on control s edges and corners.
• Properties can be set at design time by using the properties window or at run time by using statements in the program code.


2. Toolbox Controls

2.1 Form Object
The Form object is where the user interface is drawn. It is central to the development of Visual Basic application.




? Form properties

? Appearance: Value 1 makes the Form look like three dimensional. Value 0 makes the form look like flat.
Setting: It can be changed from properties window.

? Name: It gives the name of the Form which appears in the code. The default value is Form.
Setting: It can be changed from properties window.

? Caption: It sets the title of the Form.
Setting: It can be changed from properties window or from the program code using the statement (as an example):
Form1.Caption = "new"

? Font: It sets the Font type, Font style and Font size for the text on the Form.
Setting: It can be changed from properties window or from the program code using the statement (as an example):

Form1.FontBold = True
Form1.FontSize = 20
Form1.Font = "times new roman"

? Fore Color: It sets the color of the text on the Form.
Setting: It can be changed from the program code using the statement (as an example):
Form1.ForeColor = vbGreen

? Back Color: It sets the background color of the Form.
Setting: It can be changed from the program code using the statement (as an example):

Form1.BackColor = vbRed
? Enable: Either True if you want the Form respond to the user or False if you want the Form not respond to the user.
Setting: It can be changed from properties window.

? Visible: This property is True if you want the control to be visible on the Form False if you want the control to be hidden on the Form.
Setting: It can be changed from properties window.


2.2 Command Button Object
Command buttons give user pushbutton access to events that you place within application. The OK and Cancel buttons are examples of button controls found in many Windows applications.

? Command Button Properties

? Name: It gives the name of the form which appears in the code. The default value is Command.
Setting: It can be changed from properties window.


? Caption: This is the string that is displayed on the Command Button.
Setting: It can be changed from properties window or from the program code using the statement (as an example):
Command1.Caption = "close"

? Font: It sets the Font type, Font style and Font size for the text in the Command Button.
Setting: It can be changed from properties window or from the program code using the statement (as an example):

Command1.FontBold = True
Command1.FontSize = 20
Command1.Font = "times new roman"

? Fore Color: It sets the color of the text in the Command Button.
Setting: It can be changed from the program code using the statement (as an example):
Command1.ForeColor = vbGreen

? Back Color: It sets the background color of the Command Button.
Setting: It can be changed from the program code using the statement (as an example):
Command1.BackColor = vbRed

? Height
Setting: It can be changed from the program code using the statement:
Command1.Hieght = value

? Width
Setting: It can be changed from the program code using the statement:
Command1.Width = value

? Top
Setting: It can be changed from the program code using the statements:
Command1.Top = value
? Left
Setting: It can be changed from the program code using the statements:
Command1.Left = value

Example1:Design a project contains a single form and four commands represent four colors (Red, Green, Yellow, Blue). When we click any these commands the background color for the Form will be changed.

Solution:


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم