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

Part3: Visual Basic controls

Share |
الكلية كلية هندسة المواد     القسم قسم هندسة المعادن     المرحلة 2
أستاذ المادة رفاه ابراهيم جبار       10/03/2019 14:42:18
2.7 Horizontal and Vertical Scroll Bars
Horizontal and Vertical Scroll Bars are widely used in Windows applications. Scroll bars provide an intuitive way to move through a list of information and make great input devices. Both types of scroll bars are comprised of three areas that can be clicked, or dragged, to change the scroll bar value as shown below:







(Vertical Scroll Bar) (Horizontal Scroll Bar)


• By clicking an end arrow, the Scroll Bar value increases a small amount.
• By clicking the bar area, the Scroll Bar value increases a large amount.
• Dragging the Scroll Bar (thumb) provides continuous motion.

? Horizontal and Vertical Scroll Bars Properties

• The main properties of a Scroll Bar are Min, Max, Value, SmallChange, and LargeChange, which are set to integers. These properties are set from code program using the following statements:

– Horizontal Scroll Bar
HScroll1.Min=value
HScroll1.Max=value
HScroll1.SmallChange=value
HScroll1. LargeChange =value
– Vertical Scroll Bar
VScroll.Min=value
VScroll.Max=value
VScroll. SmallChange =value
VScroll. LargeChange =value

• The prefix hsb is used for naming horizontal scroll bar.
• The prefix vsb is used for naming Vertical scroll bar.





Example1: Design a Visual Basic project contains a single Form, one Label, one TextBox and one HSB, represents the Font size of the text" Hello". The HSB value is displayed in the Label. The Text will be enlarged according to the HSB change. The HSB ranges from 5 to 20.

Solution:



















2.8 List Box Object
List Box is a control that provides a list of items to the user. The initial items on the list can either be specified at design time or set with code in the Form-Load event procedure.

? List Box Object Properties

• ListCount: The ListCount property returns the number of items in the list.

Setting: it can be changed from code program using the following statement:
Varname=List1.Listcount

• ListIndex: Each item in the list is identified by an index number, and ListIndex property is the index of the item currently highlighted in list box. If no item is selected, ListIndex = -1.

Setting: It can be set from code program using the following statement:
Varname=List1.Listindex

• The prefix lst is used for naming a List Box.

• The most important methods of List Box are:

• AddItem: The AddItem method adds a string to the list.
Listname.AddItem"Itemname"

• Clear: Removes all items from List Box.
Listname.Clear

• RemoveItem: The RemoveItem statement deletes the item of index from the list Listname.RemoveItem"Itemname"
Example2: Design a Visual Basic project contains a single Form, two Label (Index, Name), two TextBox, one List Box( Shams, Ali, Jawad, Manal) and one command(Information). After running the program and when we click on the command, the name will display in the Text1 and the index will display in Text2.

Solution:























2.9 Combo Box Object

The Combo Box is similar to the list box. The difference is a Combo Box includes a text box on top of a List Box.The user has the option of either typing information or just selecting the appropriate information from a list. The prefix cbo is used for naming a combo box. Two most useful types of Combo Box are:
1. Dropdown Combo Box.
2. Simple Combo Box.

Example3: Implement the Visual Basic Form that shown below:


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