![Page 1: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/1.jpg)
OBJECTIVES:• To open an existing Project called HelloWorld.• To learn how set properties using the property window and how to set them in the code.
Chapter 2 Gaddis Book Dr. Scanlan Notes
SETTING THE MOST OFTEN USED TEXTBOX, BUTTON, LABEL, PICTUREBOX PROPERTIES,USING THE PROPERIES WINDOW AND CODE.
![Page 2: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/2.jpg)
OBJECTIVES:•To learn how set properties using the property window and how to set them in the code using a simple "Hello World" type of program.
Chapter 2 Gaddis Book Dr. Scanlan Notes
SETTING THE MOST OFTEN USED TEXTBOX, BUTTON, LABEL, PICTUREBOX PROPERTIES,USING THE PROPERIES WINDOW AND CODE.
![Page 3: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/3.jpg)
TEXTBOX
A TextBox is used for:1. Outputting information onto a Form.
2. Inputting data into a program for processing. Typically it is used for inputting data.
TEXTBOXES
![Page 4: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/4.jpg)
Setting Properties Using Property Window
Program's Purpose: Illustrates property settings.When the button is pressed, the GUI displays as seenbelow:
Dr. Scanlan: Program this with the class following. Set text size to 18 points.
TextBox1:MultiLine: TrueTextAlign: Center
Label1:AutoSize: TrueFont: Microsoft Sans Serif, Bold, 18 pointsBackColor: GrayForeColor: WhiteTextAlign: MiddleCenter
Label2:AutoSize: FalseBackColor: WhiteForeColor: RedBorderStyle: Fixed3DTextAlign: MiddleCenter
Don't forget this:
![Page 5: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/5.jpg)
Setting Properties Using Property Window
Program's Purpose: Illustrates property settings.When the button is pressed, the GUI displays as seenbelow:
Dr. Scanlan: Program this with the class following. Set text size to 18 points.
Not all the code is showing for this line.
Causes a NewLine to be started.
![Page 6: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/6.jpg)
FIND AND LOAD YOUR HELLO WORLD PROGAM.START HERE.
TEXTBOXES
![Page 7: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/7.jpg)
This is a Textbox OBJECT.
This is a PROPERTY of the Textbox OBJECT.
TEXTBOXES
![Page 8: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/8.jpg)
This is a Textbox OBJECT.
This is a PROPERTY of the Textbox OBJECT.
TEXTBOXES
This string of characters, Hello World, is called DATA.
![Page 9: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/9.jpg)
“Replace Me” will be replacewith “Hello World” when Button1 is pressed. See nextslide.
Place “Replace Me” here and it will immediatelybe seen in the TextBox.
TEXTBOXES
![Page 10: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/10.jpg)
Press the Button1 and Hello World replaces “Replace Me”.
TEXTBOXES
![Page 11: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/11.jpg)
TextBoxes:FORECOLOR & BACKCOLOR
TEXTBOXES
![Page 12: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/12.jpg)
How to change the BACKCOLOR of a Textbox:1. Select the Textbox2. Click here3. Click here4. Click here5. Click here
TEXTBOXES
![Page 13: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/13.jpg)
How to change the FORECOLOR for a Textbox:1. Select the Textbox2. Click here3. Click here4. Click here5. Click here
TEXTBOXES
![Page 14: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/14.jpg)
TextBoxes:MULTILINE
TEXTBOXES
![Page 15: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/15.jpg)
How to select a multiline TextBox:1. Select the TextBox2. Click here
TEXTBOXES
![Page 16: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/16.jpg)
How to select a multiline TextBox (Continued)3. Click here4. OR click True here
TEXTBOXES
![Page 17: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/17.jpg)
How to select a multiline TextBox (Continued)5. RESULTS
Multiline Changed from false to true
TEXTBOXES
![Page 18: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/18.jpg)
This code will cause the following to be displayed in the multiline Textbox when Button1 is pressed. >>>>>>>>
Join or Concatenation uses the & symbol Causes a new line
Continuation of a lineof code
TEXTBOXES
![Page 19: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/19.jpg)
More than one line of text; thus Multiline.
TEXTBOXES
![Page 20: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/20.jpg)
TextBoxes:Border Styles
TEXTBOXES
![Page 21: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/21.jpg)
Three different border styles:1. None2. FixedSingle3. Fixed3D
TEXTBOXES
![Page 22: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/22.jpg)
TextBoxes:Selecting Fonts
TEXTBOXES
![Page 23: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/23.jpg)
Click here
Next, Click here
See next slide for result >>>>>
TEXTBOXES
![Page 24: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/24.jpg)
Choose a font then press OK.
Three of the many font possibilities.
TEXTBOXES
![Page 25: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/25.jpg)
TextBoxes:INPUT & OUTPUT
TEXTBOXES
![Page 26: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/26.jpg)
TextBox1 for INPUT
TextBox2 for OUTPUT
TEXTBOXES
![Page 27: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/27.jpg)
TextBox1 for INPUT
TextBox2 for OUTPUT
Set TextBox2 for OUTPUT ONLY (Read only)1. Select TextBox22. Click here3. Click here
TEXTBOXES
![Page 28: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/28.jpg)
TextBox1 for INPUT
TextBox2 for OUTPUT ONLY
Set TextBox2 for OUTPUT ONLY (Read only)4. Select True for ReadOnly
NOTE: If a TextBox’s ReadOnly property is set to False,the TextBox can be used to input data into the program or to output data from the program.
TEXTBOXES
![Page 29: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/29.jpg)
Place this line of code in the Button1_Click event.
Note: The contents of the Text property in TextBox1 will be assignedto the Text property in TextBox2.Example: If CSUS is typed into TextBox1, CSUS will bedisplayed in TextBox2, when Button1 is pressed.
TEXTBOXES
![Page 30: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/30.jpg)
Steps:1. Run program2. Enter CSUS in TextBox13. Press Button14. View the OUTPUT in TextBox2
TEXTBOXES
![Page 31: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/31.jpg)
ButtonsBACKCOLOR & FORECOLOR
BUTTONS
![Page 32: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/32.jpg)
How to change the BACKCOLOR of a Button:1. Select the Button2. Click here3. Click here4. Click here5. Click here
BUTTONS
![Page 33: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/33.jpg)
How to change the FORECOLOR of a Button:1. Select the Button2. Click here3. Click here4. Click here5. Click here
BUTTONS
![Page 34: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/34.jpg)
Buttons:TEXT
BUTTONS
![Page 35: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/35.jpg)
Change message on Button:1. Select Button2. Change Button1 to something different; such as Press.
BUTTONS
![Page 36: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/36.jpg)
Buttons:Text ALLIGNMENT
BUTTONS
![Page 37: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/37.jpg)
Change message on Button:1. Select Button2. If you select “TopLeft”, the word Press will be oriented in the TopLeft of the Button.
BUTTONS
![Page 38: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/38.jpg)
Labels1. Labels can be used as labels.2. Labels can be used to output data from the code.
3. Labels can never be used to input data.
LABELS
TEXT
LABELS
![Page 39: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/39.jpg)
How to put text in a Label:1. Get a label from the ToolBox.2. Select the label.3. Replace Label1 with new text, such as, Name. See next slide for results>>>>>>>
LABELS
![Page 40: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/40.jpg)
How to use a label as a label on a form.1. Change ForeColor from white to Black2. Replace Label1 with Name or any word/s you want.
LABELS
![Page 41: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/41.jpg)
How to use a label for Output:1. Drag a Label onto the Form.2. Select the Label3. Change AutoSize to False4. Change BorderStyle to Fixed3D5. Change ForeColor from White to Black
NOTE: TextBoxes can be used for bothinput and output.Labels can only be used foroutput or for labelling.
LABELS
![Page 42: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/42.jpg)
LABELS
![Page 43: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/43.jpg)
Press the Button and George Washingtonis outputted (displayed) in the Label.
LABELS
![Page 44: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/44.jpg)
BACKCOLOR1. Click here and select color.
LABELS
![Page 45: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/45.jpg)
SETTING PROPERTIES & METHODS WITHIN
THE CODE.
Forms, TextBoxs, and Labels
Setting Properties within the Code
![Page 46: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/46.jpg)
Setting Properties Within the Code
Program's Purpose: Illustrates property settings within the code.When the button is pressed, the GUI displays as seenbelow:
Dr. Scanlan: Program this with the class following. Set text size to 18 points.
Form1:Me.Text = "Setting Properties"
TextBox1:TextBox1.Multiline = True TextBox1.Size = New Size(128, 60) TextBox1.TextAlign = HorizontalAlignment.Center TextBox1.Text = "Hello" & ControlChars.NewLine & "World"
![Page 47: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/47.jpg)
Setting Properties Within the Code
Program's Purpose: Illustrates property settings within the code.When the button is pressed, the GUI displays as seenbelow:
Dr. Scanlan: Program this with the class following. Set text size to 18 points.
Label1:
Label1.AutoSize = True Label1.BackColor = Color.Gray Label1.ForeColor = Color.White Label1.Font = New System.Drawing.Font("Sans Serif", 28) Label1.Font = New System.Drawing.Font(Label1.Font, FontStyle.Bold) Label1.Text = "Hello World"
![Page 48: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/48.jpg)
Setting Properties Within the Code
Program's Purpose: Illustrates property settings within the code.When the button is pressed, the GUI displays as seenbelow:
Dr. Scanlan: Program this with the class following. Set text size to 18 points.
Label2:
Label2.AutoSize = False Label2.BackColor = Color.White Label2.ForeColor = Color.Red Label2.BorderStyle = BorderStyle.Fixed3D Label2.TextAlign = ContentAlignment.MiddleCenter Label2.Size = New Size(128, 22) Label2.Text = "Hello World"
![Page 49: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/49.jpg)
Dr. Scanlan: Program this with the class following. Set text size to 18 points.
Setting Properties Within the Code
![Page 50: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/50.jpg)
SETTING PROPERTIES & METHODS WITHIN
THE CODE.
TextBox
Setting Properties within the Code
![Page 51: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/51.jpg)
Setting Properties within the Code
Slide: TextBox1.BackColor
BackColor1. Set color in Properties Window
OR2. Set using code by executing one of these:
TextBox1.BackColor = Color.Yellow TextBox1.BackColor = Color.Blue TextBox1.BackColor = Color.Green TextBox1.BackColor = Color.Red 'There are many other colors. 'Use Intellisense.
Purpose:1. Sets the background color in the TextBox.
![Page 52: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/52.jpg)
Slide: TextBox1.BorderStyle
BorderStyle1. Set in Properties Window
OR2. Set using code by executing one of these:
TextBox1.BorderStyle = BorderStyle.None TextBox1.BorderStyle = BorderStyle.FixedSingle TextBox1.BorderStyle = BorderStyle.Fixed3D
Setting Properties within the Code
![Page 53: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/53.jpg)
Slide: TextBox1.Font
Font 1. Set in Properties Window
Setting Properties within the Code
![Page 54: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/54.jpg)
Slide: TextBox1.ForeColor
ForeColor 1. Set in Properties Window
OR2. Set using code by executing one of these:
TextBox1.ForeColor = Color.Yellow TextBox1.ForeColor = Color.Blue TextBox1.ForeColor = Color.Green TextBox1.ForeColor = Color.Red 'There are many other colors. 'Use Intellisense.
Purpose:1. Sets the foreground color in the TextBox.2. Result: ForeColor sets the text color.
Setting Properties within the Code
![Page 55: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/55.jpg)
Slide: TextBox1.Text
Text 1. Set in Properties Window
OR 2.Set using code by executing one of these:
TextBox1.Text = "Any text here" 'Clears text box TextBox1.Text = "" 'Clears text box TextBox1.Clear()
Usually this property is left empty and text is added when code is executed.
Setting Properties within the Code
![Page 56: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/56.jpg)
Slide: TextBox1.TextAlign
TextAlign 1. Set in Properties Window
OR 2.Set using code by executing one of these:
TextBox1.TextAlign = HorizontalAlignment.Left TextBox1.TextAlign = HorizontalAlignment.Center TextBox1.TextAlign = HorizontalAlignment.Right
Setting Properties within the Code
![Page 57: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/57.jpg)
Slide: TextBox1.CharacterCasing
CharacterCasing1. Set in Properties Window
OR 2.Set using code by executing one of these:
TextBox1.CharacterCasing = CharacterCasing.Lower TextBox1.CharacterCasing = CharacterCasing.Normal TextBox1.CharacterCasing = CharacterCasing.Upper
Changes inputted text to:1. Normal: Stays as typed2. Upper: Forces text to upper case3. Lower: Forces text to lower case
Important for data validation.
Setting Properties within the Code
![Page 58: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/58.jpg)
Slide: TextBox1.MaxLength
MaxLength1. Set in Properties Window
OR 2.Set using code by executing one of these:
TextBox1.MaxLength = "1" TextBox1.MaxLength = "10" TextBox1.MaxLength = "32767"
Limits how may characters can be entered into the text box :MaxLength: 1 to 32,767 characters
Important for data validation.
Setting Properties within the Code
![Page 59: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/59.jpg)
Slide: TextBox1.MultiLine
MultiLine1. Set in Properties Window
OR 2.Set using code by executing one of these:
TextBox1.Multiline = True TextBox1.Multiline = False
Settings:1. True: Allows for more than one line of text.2. False: Limits TextBox to one line of text.
Setting Properties within the Code
![Page 60: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/60.jpg)
Slide: TextBox1 (Location and Size)
Location and Size1. Set in Properties Window
OR 2.Set using code by executing one of these:
TextBox1.Location = New Point(80, 40) TextBox1.Size = New Size(128, 22)
Location Settings;1. X: Number of pixels to the left of Form12. Y: Number of pixels from top of Form 1
Size Settings:1. Width: The width of TextBox1 in pixels.2. Height: The height of TextBox1 in pixels.
Note: Location and Size are automatically updated when you move TextBox1 on the form.
All controls that you can see on Form1 have Location and Size properties.
Setting Properties within the Code
![Page 61: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/61.jpg)
Slide: TextBox1.Name
Name1. Set in the Properties Window
Name PropertyTextBox1 is NOT a meaningful name and it must be changed to a name that is meaningful.Rules:
1. Make the name as short as possible and as meaningful as possible.
2. Shift to upper case between words.3. Use txt as the prefix.
Examples:txtHoursWorkedtxtLastNametxtHourlyRatetxtSellingPrice
Setting Properties within the Code
![Page 62: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/62.jpg)
Setting Properties within the Code
SETTING PROPERTIES & METHODS WITHIN
THE CODE.
LABELS
![Page 63: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/63.jpg)
Slide: Label1.BackColor
BackColor1. Set color in Properties Window
OR2. Set using code by executing one of these:
Label1.BackColor = Color.Yellow Label1.BackColor = Color.Blue Label1.BackColor = Color.Green Label1.BackColor = Color.Red Label1.BackColor = Color.White 'There are many other colors. 'Use Intellisense.
Purpose:1. Sets the background color in the Label.
Setting Properties within the Code
![Page 64: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/64.jpg)
Slide: Label1.BorderStyle
BorderStyle1. Set in Properties Window
OR2. Set using code by executing one of these:
Label1.BorderStyle = BorderStyle.None Label1.BorderStyle = BorderStyle.FixedSingle Label1.BorderStyle = BorderStyle.Fixed3D
Setting Properties within the Code
![Page 65: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/65.jpg)
Slide: Label1.Font
Font 1. Set in Properties Window
Setting Properties within the Code
![Page 66: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/66.jpg)
Slide: Label1.ForeColor
ForeColor 1. Set in Properties Window
OR2. Set using code by executing one of these:
TextBox1.ForeColor = Color.Yellow TextBox1.ForeColor = Color.Blue TextBox1.ForeColor = Color.Green TextBox1.ForeColor = Color.Red 'There are many other colors. 'Use Intellisense.
Purpose:1. Sets the foreground color in the Label.2. Result: ForeColor sets the text color.
Setting Properties within the Code
![Page 67: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/67.jpg)
Slide: Label1.Text
Text 1. Set in Properties Window
OR 2.Set using code by executing one of these:
Label1.Text = "Any text here" 'Clears text box Label1.Text = "" 'Clears text box Label1.Clear()
Setting Properties within the Code
![Page 68: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/68.jpg)
Slide: Label1.TextAlign
TextAlign 1. Set in Properties Window
OR 2.Set using code by executing one of these:
Label1.TextAlign = ContentAlignment.MiddleCenter Label1.TextAlign = ContentAlignment.MiddleLeft Label1.TextAlign = ContentAlignment.MiddleRight 'For the six other settings, use intellisense.
Setting Properties within the Code
![Page 69: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/69.jpg)
Slide: Label1 (Location and Size)
Location and Size1. Set in Properties Window
OR 2.Set using code by executing one of these:
Label1.Location = New Point(56, 40) Label1.Size = New Size(160,16)
Location Settings;1. X: Number of pixels to the left of Form12. Y: Number of pixels from top of Form 1
Size Settings:1. Width: The width of Label1 in pixels.2. Height: The height of Label1 in pixels.
Note: Location and Size are automatically set when you move Label1 on the form.
Setting Properties within the Code
![Page 70: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/70.jpg)
Slide: Label1.Name
Name1. Set in the Properties Window
Name PropertyLabel1 is NOT a meaningful name and it must be changed to a name that is meaningful.Rules:
1. Make the name as short as possible and as meaningful as possible.
2. Shift to upper case between words.3. Use lbl as the prefix.
Examples:lblDisplayHoursWorkedlblDisplayLastNamelblDisplayHourlyRatelblDisplaySellingPrice
Rules for Creating Meaningful Names
![Page 71: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/71.jpg)
TextBoxes vs. Labels
TextBoxes
• Used for data input.
• Used for output, only if you need more than one line.
Labels
• Used for output
![Page 72: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/72.jpg)
PictureBox1. Allows for placing a picture on the
form.2. Has properties, as do most controls.3. Has events, as do most controls.
PICTUREBOX CONTROL
PICTURE BOX
![Page 73: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/73.jpg)
PICTURE BOX
Purpose: This example program illustrates the PictureBox property. It also illustrates the Visual property of a Label that has been set to False in the Properties window and set to True in the code.Code: lblDirections.Visible = True
Dr. Scanlan: Program this with the class following. Set code text size to 18 points.
These directions become Visible when the "Display Directions" button is pressed.
![Page 74: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/74.jpg)
PICTURE BOX
'THIS CODE IS EXECUTED WHEN THE BUTTON IS PRESSED.
When the button is pressed, the label's text property isDisplayed.
[Missing code}
[Missing code}
Requirements:1. Place the objects on the form as seen below.2. Place the directions in the text property of lblDirections.Text3. Write to code below.
![Page 75: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/75.jpg)
PICTURE BOX
PictureBox Control1. The PictureBox allows the programmer to place a picture on the Form. (a) The PictureBox can respond to a variety of events, such as a click event.2. These slides illustrate:
(a) Placing a picture on the form.(b) A click event causing a message to be displayed.
Double click on the PictureBoxControl or drag it onto the Form
![Page 76: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/76.jpg)
PICTURE BOX
PictureBox Control1. PictureBox Tasks (Options)
Click here to view options
PictureBox Control
![Page 77: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/77.jpg)
PICTURE BOX
PictureBox Control1. PictureBox Tasks (Options)
Find an image to put in thePictureBox
![Page 78: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/78.jpg)
PICTURE BOX
PictureBox Control1. PictureBox Tasks (Options)
Find (Import) an image and place itin the Resources.resx filethat is under the Solutions.slnFile.
Press Import button tolook for your desired Picture.
![Page 79: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/79.jpg)
PICTURE BOX
PictureBox Control1. PictureBox Tasks (Options)
I imported the picture, HotelMap, which isdisplayed.
Next, press OK
![Page 80: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/80.jpg)
PICTURE BOX
PictureBox Control1. PictureBox Tasks (Options)
The Image is now in theTextBox. You have fourOptions:1. Normal: The full size of the image is displayed and you can use the handles to displayall or part of the picture.2. StretchImage: Allows for sizing the image…Make it bigor make it small. Proportions can be changed.3. AutoSize: The picture boxis sized to the size of the picture.4. Zoom: Allows for sizing thepicture while maintaining isproportions.
![Page 81: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/81.jpg)
VISIBLE PROPERTY
'CODE EXECUTED BY PRESSING BUTTON1
Program not running Program running Button1 was pressed
Purpose: This program illustrates changing Label1 from being invisible to visible by pressing a button. Note the code below. Label1's Visible
Property was set to False in the Properties window.
![Page 82: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/82.jpg)
Quick Look at CheckBoxes, RadioButtons, and IF-THEN-ELSE
The following slides are a brief introduction to Check Boxes, Radio Buttons and IF-THEN-ELSE statements.
These topics will be covered in detail in later chapters.
![Page 83: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/83.jpg)
Quick Look at CheckBoxes, RadioButtons, and IF-THEN-ELSE
IF-THEN-ELSE STATEMENT
Play first two videos for Chapter 4
![Page 84: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/84.jpg)
Quick Look at CheckBoxes, RadioButtons, and IF-THEN-ELSE
Public Class Form1 'CLICK BUTTON FOR DISCOUNT Private Sub btnPress_Click(sender As System.Object, e As
System.EventArgs) Handles btnPress.Click If chkVIPDiscount.Checked = True Then lblDisplayDiscount.Text = "$25.00" End If End SubEnd Class
SIMPLE CHECK BOX EXAMPLE
![Page 85: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/85.jpg)
Quick Look at CheckBoxes, RadioButtons, and IF-THEN-ELSE
REALISTIC CHECK BOX EXAMPLE
Code >>>>
![Page 86: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/86.jpg)
Quick Look at CheckBoxes, RadioButtons, and IF-THEN-ELSE
CHECK BOX EXAMPLE (CODE)Public Class Form1 Const VIPDiscount As Decimal = 25D Const AARPDiscount As Decimal = 15D
'CALCULATE DISCOUNTS Private Sub btnCalcDiscount_Click(sender As System.Object, e As
System.EventArgs) Handles btnCalcDiscount.Click If chkVIPMember.Checked = True And chkAARP.Checked = True Then lblTotalDiscounts.Text = FormatCurrency(VIPDiscount + AARPDiscount) ElseIf chkVIPMember.Checked = True Then lblTotalDiscounts.Text = FormatCurrency(VIPDiscount) ElseIf chkAARP.Checked = True Then lblTotalDiscounts.Text = FormatCurrency(AARPDiscount) End If End Sub
'CLEAR ENTRIES Private Sub btnClearEntries_Click(sender As System.Object, e As
System.EventArgs) Handles btnClearEntries.Click chkAARP.Checked = False chkVIPMember.Checked = False lblTotalDiscounts.Text = "" End SubEnd Class
LAST SLIDE
![Page 87: OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter](https://reader035.vdocument.in/reader035/viewer/2022062500/56649f1e5503460f94c367cc/html5/thumbnails/87.jpg)
Public Class Form1 Const decLuxuryRoomPrice As Decimal = 275D Const decStandardRoomPrice As Decimal = 125D
'COMPUTE PRICE Private Sub btnComputePrice_Click(sender As System.Object, e As System.EventArgs) Handles btnComputePrice.Click If radLuxuryRoom.Checked = True Then lblDisplayPrice.Text = FormatCurrency(decLuxuryRoomPrice) ElseIf radStandardRoom.Checked = True Then lblDisplayPrice.Text = FormatCurrency(decStandardRoomPrice) End If End SubEnd Class
Quick Look at CheckBoxes, RadioButtons, and IF-THEN-ELSE
RADIO BUTTON EXAMPLE -- SIMPLE