VB6.0 – 02 - More Basic Objects
An introductory course.
Presented by Charley Jones, Manpower Professional,
Course WebPage:
Review:
Last week we covered:
ObjectsNounsCar, Form, Button
PropertiesAdjectivesCar.Color, Form.Left, Button.Caption
MethodsActionsCar.Drive, Form.Move, Button.Hide
EventsTriggerForm_Load(), Button_Clicked()
ApplicationHolds data on our project.App.Title, App.Version
FormsBasic display unit in VB.Form.Caption
CommandButtonAllows action on form.Button.Caption
TextBoxAccepts / displays input.Text1.Text
New Objects:
Labels:
Allow for descriptive text on forms.
Label.CaptionText to be displayed.
Label.FontFont to be used.
List Boxes:
Allow for the selection of one or more items from a list.
List.AddItem(string, [index])List1.AddItem “Test”
List.Clear()Clears textbox.
List.Style0=Normal, 1=Checkbox
List.List()List of values.
List.ListCountNumber of items in list.
List.MultiSelect0=One only, 2=Many
List.Selected(x)Whether item is selected.
ComboBox:
Also called a pull-down or Combo.
Cross between a listbox and textbox.
Allows entry like a text box, or selection from list.
Combo1.TextValue Chosen.
Check Box:
Allows for On/Off input.
Check1.ValueReturn from Checkbox: 1/0
Radio Buttons:
Allows for one selection in a group.
Groups are controlled by Frames.
When one is selected, all others in group unselected.
Option1.Value Return from Checkbox: True/False
Frames:
Provides separation on forms, grouping of Radio buttons.
Frame.Caption
Some Basic Coding:
Dim
Creates storage for a variable.
Dim sTitle as String
Dim iNumber as Integer
If
Perform action based on condition
IF Condition THEN Action
IF Option1.Value then Label1.Caption = “Option1”
IF Condition THEN
ACTIONS
ELSE
ACTIONS
ENDIF
If Option1.Value then
Label1.Caption = “Option1”
Else
Label1.Caption = “Not Option1”
Endif
For
Create a counting / looping condition
For X = 1 to 10
If List1.Selected(X) then Label1.Caption = List1.List(X)
Next X
Do While
Creates a loop.
X=1
Do while X<10
If List1.Selected(X) then
Label1.Caption = List1.List(X)
Exit Do
Endif
X=X+1
LOOP
Form_Load
Where we do our initialization work.
Label1.Caption = App.Title
Label2.Caption = App.Major& “.” & App.Minor & “.” & App.Revision
List1.AddItem “Test”
List1.AddItem “Test2”
Class Challenges:
Challenge 2-1:
Revise the ING, ED, S project to use a listbox with checkboxes.
Use a single button to “Create Word.”
Challenge 2-2:
Create a new application to create a list of words,
(Blank list to start, user adds one word at a time through textbox.)
Use Radio Buttons to select between ING, ED, and S.
Create a new list with each word + ending when “Create Words” button is pushed.
VB6-02- 1 -