Programming In Visual Basic 2008 7th Edition 7th Julia Case Bradley
Programming In Visual Basic 2008 7th Edition 7th Julia Case Bradley
Programming In Visual Basic 2008 7th Edition 7th Julia Case Bradley
Programming In Visual Basic 2008 7th Edition 7th Julia Case Bradley
1. Programming In Visual Basic 2008 7th Edition 7th
Julia Case Bradley download
https://ebookbell.com/product/programming-in-visual-
basic-2008-7th-edition-7th-julia-case-bradley-2417356
Explore and download more ebooks at ebookbell.com
2. Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Adonet Programming In Visual Basic Net 2nd Edition Steven Holzner
https://ebookbell.com/product/adonet-programming-in-visual-basic-
net-2nd-edition-steven-holzner-923610
Windows Forms Programming In Visual Basic Net Chris Sells Justin
Ghetland
https://ebookbell.com/product/windows-forms-programming-in-visual-
basic-net-chris-sells-justin-ghetland-982348
Design Patterns And Object Oriented Programming In Visual Basic 6 And
Vbnet James W Cooper
https://ebookbell.com/product/design-patterns-and-object-oriented-
programming-in-visual-basic-6-and-vbnet-james-w-cooper-43710818
Network Programming In Net With C And Visual Basic Net Fiach Reid
https://ebookbell.com/product/network-programming-in-net-with-c-and-
visual-basic-net-fiach-reid-4110194
3. Programming In Visual Basic 2010 8th Edition Bradley Julia Case
https://ebookbell.com/product/programming-in-visual-basic-2010-8th-
edition-bradley-julia-case-55132378
Programming In Visual Basic 2010 The Very Beginners Guide 1st Edition
Mckeown
https://ebookbell.com/product/programming-in-visual-basic-2010-the-
very-beginners-guide-1st-edition-mckeown-55139938
Programming In Visual Basic Vb Olga Maria Stefania Cucaro
https://ebookbell.com/product/programming-in-visual-basic-vb-olga-
maria-stefania-cucaro-46098642
A Guide To The Practical Issues And Applications In Database
Programming With Updated Visual Basicnet Murillo
https://ebookbell.com/product/a-guide-to-the-practical-issues-and-
applications-in-database-programming-with-updated-visual-basicnet-
murillo-44123730
Programming In Visual C 2008 Julia Case Bradley Anita C Millspaugh
https://ebookbell.com/product/programming-in-visual-c-2008-julia-case-
bradley-anita-c-millspaugh-36155348
6. PROGRAMMING IN
VISUAL BASIC 2008
Julia Case Bradley
Mt. San Antonio College
Anita C. Millspaugh
Mt. San Antonio College
bra17208_fm_i-xxviii 4/11/08 9:17PM Page i ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
8. Visual Basic (VB) has become such a popular programming language for sev-
eral reasons. VB is easy to learn, which makes it an excellent tool for under-
standing elementary programming concepts. In addition, it has evolved into
such a powerful and popular product that skilled Visual Basic programmers are
in demand in the job market.
Visual Basic is fully object-oriented and compatible with many other
languages using the .NET Framework. This book incorporates the object-
oriented concepts throughout, as well as the syntax and terminology of the
language.
Visual Basic is designed to allow the programmer to develop applications
that run under Windows and/or in a Web browser without the complexity gener-
ally associated with programming. With very little effort, the programmer can
design a screen that holds standard elements such as buttons, check boxes, radio
buttons, text boxes, and list boxes. Each of these objects operates as expected,
producing a “standard” Windows or Web user interface.
About This Text
This textbook is intended for use in an introductory programming course, which
assumes no prior knowledge of computer programming. The later chapters are
also appropriate for professional programmers who are learning a new language
to upgrade their skills.
This text assumes that the student is familiar with the Windows operating
environment and can use an Internet browser application.
Approach
This text incorporates the basic concepts of programming, problem solving,
programming logic, as well as the design techniques of an object-oriented,
event-driven language. VB is a fully object-oriented language, which includes
inheritance and polymorphism. Object-oriented programming (OOP) is intro-
duced in Chapter 1, and its features appear in every chapter of the book.
Chapter topics are presented in a sequence that allows the programmer to
learn how to deal with a visual interface while acquiring important program-
ming skills such as creating projects with objects, decisions, loops, and data
management.
A high priority is given to writing applications that are easy for the user to
understand and to use. Students are presented with interface design guidelines
throughout the text.
iii
PREFACE
bra17208_fm_i-xxviii 4/11/08 9:17PM Page iii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
9. Text Features
Object-Oriented Concepts
are presented throughout the text to offer
students an introduction to object-oriented
design before learning to create their own
classes.
Try
' Convert quantity to numeric variable.
QuantityInteger = Integer.Parse(QuantityTex
Try
' Convert price if quantity was successf
PriceDecimal = Decimal.Parse(PriceTextBo
' Calculate values for sale.
ExtendedPriceDecimal = QuantityInteger *
DiscountDecimal = Decimal.Round((Extende
DiscountedPriceDecimal = ExtendedPriceDe
‘ Calculate summary values.
QuantitySumInteger += QuantityInteger
DiscountSumDecimal += DiscountDecimal
DiscountedPriceSumDecimal += DiscountedP
SaleCountInteger += 1
AverageDiscountDecimal = DiscountSumDeci
C H A P T E R
2
User Interface
Design
at the completion of this chapter, you will be able to . . .
1. Use text boxes, masked text boxes, rich text boxes, group boxes, check
boxes, radio buttons, and picture boxes effectively.
2. Set the BorderStyle property to make controls appear flat or three-dimensional.
3. Select multiple controls and move them, align them, and set common properties.
4. Make your projects easy for the user to understand and operate by defining
access keys, setting an Accept and a Cancel button, controlling the tab
sequence, resetting the focus during program execution, and causing
ToolTips to appear.
5. Clear the contents of text boxes and labels.
6. Make a control visible or invisible at run time by setting its Visible property.
7. Disable and enable controls at design time and run time.
8. Change text color during program execution.
9. Code multiple statements for one control using the With and End With
statements.
10. Concatenate (join) strings of text.
11. Download the Line and Shape controls, add them to the toolbox, and use the
controls on your forms.
100 V I S U A L B A S I C User Interface Design
Good Programming Habits
1. Always test the tab order on your forms. Fix it if necessary by changing
the TabIndex properties of the controls.
2. Provide visual separation for input fields and output fields and always
make it clear to the user which are which.
3. Make sure that your forms can be navigated and entered from the key-
board. Always set an Accept button (AcceptButton property) for every
form.
4. To make a label maintain its size regardless of the value of the Text
property, set AutoSize to False.
5. To make the text in a text box right justified or centered, set the
TextAlign property.
6. You can use the Checked property of a check box to set other properties
that must be True or False.
Interface Guidelines
are presented to offer students a better
understanding of meeting user needs
and employing industry standards.
Bradley_Walkthru.indd Page 2 4/12/08 2:47:49 PM user-s175 /Users/user-s175/Desktop/TEMPWORK/APRIL/12:04:08/MHBR023
bra17208_fm_i-xxviii 4/12/08 2:58PM Page iv ntt Os9:Desktop Folder:TEMPWORK:Don't Delete (Jobs):MHBR023/Bradley:
10. Feedback Questions
give students time to reflect on the
current topic and to evaluate their
understanding of details.
Tips
in the margins help students avoid
potential trouble spots in their
programs and encourage them to
develop good programming
habits.
➤
304 V I S U A L B A S I C Lists, Loops, and Printing
Feedback 7.3
1. Identify the statements that are correctly formed and those that have er-
rors. For those with errors, state what is wrong and how to correct it.
(a) For IndexDecimal = 3.5D To 6.0D, Step 0.5D
Next IndexDecimal
(b) For IndexInteger = BeginInteger To EndInteger Step IncrementInteger
Next EndInteger
(c) For 4 = 1 To 10 Step 2
Next For
(d) For IndexInteger = 100 To 0 Step –25
Next IndexInteger
(e) For IndexInteger = 0 To –10 Step –1
Next IndexInteger
(f) For IndexInteger = 10 To 1
Next IndexInteger
2. How many times will the body of the loop be executed for each of these
examples? What will be the value of the loop index after normal com-
pletion of the loop?
(a) For CountInteger = 1 To 3
(b) For CountInteger = 2 To 11 Step 3
(c) For CountInteger = 10 To 1 Step –1
(d) For CounterDecimal = 3.0D To 6.0D Step 0.5D
(e) For CountInteger = 5 To 1
Making Entries Appear Selected
You can use several techniques to make the text in a text box or list appear
selected.
Selecting the Entry in a Text Box
142 V I S U A L B A S I C Variables, Constants, and Calculations
Fortunately, the Visual Studio smart editor helps you enter the arguments;
you don’t have to memorize or look up the argument lists. Type
“MessageBox.Show(” and IntelliSense pops up with the first of the signatures
for the Show method (Figure 3.8). Notice in the figure that there are 21 possi-
ble forms of the argument list, or 21 signatures for the Show method. (We only
showed 4 of the 21 signatures in the previous example, to simplify the concept.)
To select the signature that you want to use, use the up or down arrows at
the left end of the IntelliSense popup. For example, to select the signature that
needs only the text of the message and the title bar caption, select the 14th for-
mat (Figure 3.9). The argument that you are expected to enter is shown in bold,
and a description of that argument appears in the last line of the popup. After
you type the text of the message and a comma, the second argument appears in
bold and the description changes to tell you about that argument (Figure 3.10).
F i g u r e 3 . 8
IntelliSense pops up the first of 21 signatures for the Show method. Use the up and down arrows to see the other possible
argument lists.
You can use the keyboard up
and down arrow keys rather than
the mouse to view and select the
signature. ■
TIP
➤
172 V I S U A L B A S I C Decisions and Conditions
Feedback 4.2
Assume that FrogsInteger = 10, ToadsInteger = 5, and PolliwogsInteger
= 6. What will be displayed for each of the following statements?
1. If FrogsInteger > PolliwogsInteger Then
FrogsRadioButton.Checked = True
Else
FrogsRadioButton.Checked = False
End If
2. If FrogsInteger > ToadsInteger + PolliwogsInteger Then
ResultTextBox.Text = "It's the frogs."
Else
ResultTextBox.Text = "It's the toads and the polliwogs."
End If
3. If PolliwogsInteger > ToadsInteger And FrogsInteger <> 0 _
Or ToadsInteger = 0 Then
ResultTextBox.Text = "It's true."
Else
ResultTextBox.Text = "It's false."
End If
4. Write the statements necessary to compare the numeric values stored
in ApplesTextBox.Text and OrangesTextBox.Text. Display in Most-
TextBox.Text which has more, the apples or the oranges.
5. Write the Basic statements that will test the current value of Bal-
anceDecimal. When BalanceDecimal is greater than zero, the check
box for Funds Available, called FundsCheckBox, should be selected,
the BalanceDecimal set back to zero, and CountInteger incremented by
one. When BalanceDecimal is zero or less, FundsCheckBox should not
be selected (do not change the value of BalanceDecimal or increment
the counter).
Using If Statements with Radio Buttons
and Check Boxes
In Chapter 2 you used the CheckedChanged event for radio buttons and check
boxes to carry out the desired action. Now that you can use If statements, you
should not take action in the CheckedChanged event procedures for these con-
l I d d i hi h i l d
Indentation can help you catch er-
rors. Visual Basic always matches
an Else with the last unmatched
If regardless of the indentation. ■
TIP
Bradley_Walkthru.indd Page 3 4/12/08 2:47:59 PM user-s175 /Users/user-s175/Desktop/TEMPWORK/APRIL/12:04:08/MHBR023
bra17208_fm_i-xxviii 4/12/08 2:58PM Page v ntt Os9:Desktop Folder:TEMPWORK:Don't Delete (Jobs):MHBR023/Bradley:
11. Your Hands-On
Programming Examples
guide students through the process of
planning, writing, and executing Visual Basic
programs.
access level 268
About box 257
Friend 268
Hide method 263
modal 262
modeless 262
namespace 269
Private 268
Public 268
scope 267
Show method 262
ShowDialog method 262
splash screen 260
startup form 254
Static 268
C H A P T E R 6 283
K e y T e r m s
R e v i e w Q u e s t i o n s
1. List some of the items generally found in an About box.
2. What is the purpose of a splash screen?
3. What is the term used for the first form to display in a project?
4. How can you choose a different form as the startup form after the project
has been created?
5. Explain how to include an existing form in a new project.
6. What is the assembly information? How can you change the information?
How can you use the information?
7. Explain the difference between modal and modeless.
8. How does the Show method differ from the ShowDialog method?
9. Explain when the form’s Load event and Activated event occur. In which
event procedure should you place code to initialize screen fields? Is the
answer always the same?
10. Explain the differences between Public, Private, and Friend access
levels.
11. What is a static variable? When would it be useful?
12. How can you run a compiled VB program outside the Visual Studio IDE?
P r o g r a m m i n g E x e r c i s e s
Note: For help in basing a new project on an existing project, see “Copy and
Move a Project” in Appendix C.
6.1 Modify Programming Exercise 5.5 (the flag viewer) to include a splash
screen and an About box.
Menus
File Country Display Help
Exit United States Title About
Canada Country Name
Japan Programmer
Mexico
6.2 Create a project that will produce a summary of the amounts due for Pat’s
Auto Repair Shop. Display a splash screen first; then display the main form,
which has only the menus. If you wish, you can add a graphic to the form.
286 V I S U A L B A S I C Multiform Projects
Case Studies
Video Bonanza
Modify the Video Bonanza project from Chapter 5 to
separate the project into multiple forms. Include a
summary form, a splash screen, and an About box.
Very Very Boards
Modify the Very Very Boards project from Chapter 5 to
separate the project into multiple forms. Include a
summary form, a splash screen, and an About box.
VB Auto Center
Create a project that uses four forms. Add the form
from the Chapter 5 VB Auto case study and create a
main form, a splash screen, and an About box.
Main Form: The main form should display a large la-
bel with the words: “Valley Boulevard Auto Center -
Meeting all your vehicle’s needs” and appropriate
image(s).
Main Form Menus
File Edit Help
Input Sale Color... About
Exit Font...
The Color and Font items should allow the user to
change the large label on the form.
The Input Sale item should display the form from
Chapter 5.
Modify the VB Mail Order project from Chapter 5 to
include a splash screen, an About box, and a summary
form. Include an image on both the Splash form and
the About box.
VB Mail Order
Case Studies
provide continuing-theme exercises that
may be used throughout the course,
providing many opportunities to expand
on previous projects.
Text Features
3. The PrintPage event.
4. The DrawString method.
5. System.Drawing.Printing.PrintPageEventArgs.
6. MarginBounds.Left.
7. The PrintPreviewDialog component.
Your Hands-On Programming Example
Create a project for R ’n R—for Reading ’n Refreshment that contains a drop-
down combo box of the coffee flavors and a list box of the syrup flavors. Adjust
the size of the boxes as needed when you test the project. The controls should
have labels above them with the words Coffee and Syrup. Enter the initial val-
ues for the syrup flavors and coffee flavors in the Properties window. Set the
Sorted property of both lists to True. The user will be able to add more coffee
flavors to the list at run time by typing in the top portion of the combo box and
selecting a menu item.
Coffee Flavors Syrup Flavors
Espresso Roast (None)
Jamaica Blue Mountain Chocolate
Kona Blend Hazelnut
Chocolate Almond Irish Cream
Vanilla Nut Orange
Programming
Exercises
test students' understanding of the
specific programming skills covered in
that chapter.
Bradley_Walkthru.indd Page 4 4/12/08 2:48:07 PM user-s175 /Users/user-s175/Desktop/TEMPWORK/APRIL/12:04:08/MHBR023
bra17208_fm_i-xxviii 4/12/08 2:58PM Page vi ntt Os9:Desktop Folder:TEMPWORK:Don't Delete (Jobs):MHBR023/Bradley:
12. Visit the VISUAL BASIC 2008 Web site at:
http://www.mhhe.com/VB2008/ for
instructor and student resources.
For the Student
Student Data
available on the text
,
s Web
site offers a debugging
project, database files for the
programming exercises and
case studies, graphics, and
sound files.
Bradley_Walkthru.indd Page 5 4/12/08 2:48:15 PM user-s175 /Users/user-s175/Desktop/TEMPWORK/APRIL/12:04:08/MHBR023
bra17208_fm_i-xxviii 4/12/08 2:58PM Page vii ntt Os9:Desktop Folder:TEMPWORK:Don't Delete (Jobs):MHBR023/Bradley:
13. Instructor Web Site
includes: Instructor Manual with teaching hints,
outlines, and a matrix of the chapter features
required for each programming exercise;
PowerPoint Slides; Testing Files (using EZ Test
and in Word files); as well as Solutions to End-
of-Chapter Exercises.
For the Instructor
Bradley_Walkthru.indd Page 6 4/12/08 2:48:22 PM user-s175 /Users/user-s175/Desktop/TEMPWORK/APRIL/12:04:08/MHBR023
bra17208_fm_i-xxviii 4/12/08 2:58PM Page viii ntt Os9:Desktop Folder:TEMPWORK:Don't Delete (Jobs):MHBR023/Bradley:
14. PowerPoint Presentations
provide instructors with complete, detailed
presentations that walk students through the
important concepts covered in each chapter.
Visit the VISUAL BASIC 2008 Web site at:
http://www.mhhe.com/VB2008/ for
instructor and student resources.
Bradley_Walkthru.indd Page 7 4/18/08 3:08:52 PM user-s175 /Users/user-s175/Desktop/TEMPWORK/APRIL/18:04:08/MHBR023
bra17208_fm_i-xxviii 04/18/2008 3:07 pm Page ix pinnacle OSX:Desktop Folder:TEMPWORK:Don't Delete (Jobs):MHBR023/Bradley:
15. Changes in This Edition
This revision of the text is based on the Professional Edition of Visual Basic
2008. The 2008 version of VB includes Language Integrated Queries (LINQ)
for a more consistent means of querying a variety of data sources. XML literals
make it easier to read and write XML files. The Windows Presentation Foun-
dation (WPF) brings new dimensions to interface design.
The Editor now has a much richer IntelliSense that makes it unnecessary
to use the Me keyword in most instances.
This version now contains a PrintForm control that is very convenient for the
classroom environment. The PrintForm is covered in Chapter 1 for output to either
the printer or a Print Preview. Standard printing is still covered in Chapter 7.
LINQ is covered in Chapter 10 (“Database Applications”) and again in the
XML section of Chapter 14.
Chapter 11 (“Data Files”) includes a method for writing small amounts of
data using the My object.
Drag-and-drop for images is now covered in the graphics chapter (Chapter
13). Students learn the development techniques for this familiar operation.
Chapter 14 includes XML data files and an introduction to programming
with WPF.
The narrative, step-by-step exercises, screen captures, and appendices
have all been updated to VB 2008. The screen captures are all based on
Windows Vista.
Changes to coding conventions include the use of Pascal casing for
variable identifiers.
Features of This Text
Each chapter begins with identifiable objectives and a brief overview. Numer-
ous coding examples as well as hands-on projects with guidance for the plan-
ning and coding appear throughout. Thought-provoking feedback questions
give students time to reflect on the current topic and to evaluate their under-
standing of the details. The end-of-chapter items include a chapter review,
questions, programming exercises, and four case studies.
Chapter 1, “Introduction to Visual Basic 2008,” introduces
Microsoft’s Visual Studio integrated development environment (IDE). The
single environment is used for multiple programming languages. A step-
by-step program gets students into programming very quickly (quicker
than most books). The PrintForm control is included to allow students to
easily submit screen captures of the form at run time. The chapter
introduces the OOP concepts of objects, properties, methods, and events.
The elements of debugging and using the Help system are also
introduced.
Chapter 2, “User Interface Design,” demonstrates techniques for
good program design, including making the interface easy for users as
well as guidelines for designing maintainable programs. Several controls
are introduced, including text boxes, rich text boxes, masked text boxes,
group boxes, check boxes, radio buttons, picture boxes, and the new
Shape and Line controls.
x P R E F A C E
bra17208_fm_i-xxviii 4/11/08 9:18PM Page x ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
16. P R E F A C E xi
Chapter 3, “Variables, Constants, and Calculations,” presents the
concepts of using data and declaring the data type. Students learn to
follow standards to indicate the data type and scope of variables and
constants and always to use Option Strict, which forces adherence to
strong data typing.
Error handling is accomplished using structured exception handling.
The Try/Catch/Finally structure is introduced in this chapter along
with calculations. The student learns to display error messages using the
MessageBox class and also learns about the OOP concept of overloaded
constructors.
Chapter 4, “Decisions and Conditions,” introduces taking alternate
actions based on expressions formed with the relational and logical
operators. This chapter uses the If statement to validate input data.
Multiple decisions are handled with both nested If statements and the
Select Case structure.
The debugging features of the IDE are covered, including a step-by-
step exercise that covers stepping through program statements and
checking intermediate values during execution.
Chapter 5, “Menus, Common Dialog Boxes, Sub Procedures,
and Function Procedures,” covers the concepts of writing and calling
general sub procedures and function procedures. Students learn to
include both menus and context menus in projects, display the Windows
common dialog boxes, and use the input provided by the user.
Chapter 6, “Multiform Projects,” adds splash forms and About forms
to a project. Summary data are presented on a separate form. The Friend
keyword is introduced.
Chapter 7, “Lists, Loops, and Printing,” incorporates list boxes and
combo boxes into projects, providing the opportunity to discuss looping
procedures and printing lists of information. Printing is accomplished
in .NET using a graphics object and a callback event. The printing
controls also include a Print Preview, which allows students and
instructors to view output without actually printing it.
Chapter 8, “Arrays,” introduces arrays, which follow logically from
the lists covered in Chapter 7. Students learn to use single- and
multidimension arrays, table lookups, and arrays of structures.
Chapter 9, “Web Applications,” introduces Web applications using
Web Forms. Students learn to design and develop simple Web
applications that consist of Web pages that execute in a browser
application. Multiple-page Web sites are covered along with validator
controls and an introduction to state management.
Chapter 10, “Database Applications,” introduces ADO.NET, which
is Microsoft’s latest technology for accessing data in a database. This
chapter shows how to create binding sources, table adapters, and
datasets. Programs include accessing data from both Windows Forms and
Web Forms. Students learn to bind data tables to a data grid and bind
individual data fields to controls such as labels and text boxes. LINQ is
used to query system processes.
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xi ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
17. Chapter 11, “Data Files,” presents the VB object-oriented
techniques for data file handling. Students learn to save and read small
amounts of data using the My object and using streams. The StreamWriter
and StreamReader objects are used to store and reload the contents of a
combo box.
Chapter 12, “OOP: Creating Object-Oriented Programs,”
explains more of the theory of object-oriented programming. Although we
have been using OOP concepts since Chapter 1, in this chapter students
learn the terminology and application of OOP. Inheritance is covered for
visual objects (forms) and for extending existing classes. The samples are
kept simple enough for an introductory class.
Chapter 13, “Graphics, Animation, Sound, and Drag-and-
Drop,” covers the classes and methods of GDI+. The chapter covers
graphics objects, pens, and brushes for drawing shapes and lines.
Animation is accomplished using the Timer control and the SetBounds
method for moving controls. My.Computer.Audio.Play is used to provide
sound, and drag-and-drop events are used to transfer the contents of a
text box to a list box and to move images.
Chapter 14, “Additional Topics in Visual Basic,” introduces some
advanced VB topics. This final chapter covers validating user input using
Error Providers and the Validating event of controls. Students learn to
create applications using multiple document interfaces (MDI), create
toolbars and status bars using ToolStrip and StatusStrip controls, and add
Web content to a Windows Form using the WebBrowser control. The code
snippet feature is introduced. Reading and writing XML text files is
covered using the new XML literals and using LINQ.
An introduction to Windows Presentation Foundation (WPF) includes
using WPF interoperability with a standard Windows Form and creating a
WPF Form project.
The appendices offer important additional material. Appendix A holds
the answers to all Feedback questions. Appendix B covers methods and
functions for math, string handling, and date manipulation. In OOP style,
most actions that were formerly done with functions are now accomplished
with methods of the Math class and String class.
Appendix C, on mastering the Visual Studio environment, is based on
the .NET IDE and includes instructions for using snap lines for form
design. Appendix D discusses security issues for both Windows and Web
programming.
xii P R E F A C E
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
18. P R E F A C E xiii
Acknowledgments
Many people have worked very hard to design and produce this text. We would
like to thank our editors, Scott Davidson and Alaina Grayson. Our thanks also
to the many people who produced this text, including Marlena Pechan, Becky
Komro, and Betsy Blumenthal.
We greatly appreciate Theresa Berry of Mt. San Antonio College and Peter
van der Goes of Rose State College for their thorough technical reviews, con-
structive criticism, and many valuable suggestions. We would like to thank
Brenda Nielsen of Mesa Community College for her work in creating the
PowerPoint Presentations that accompany this text and to Theresa Berry for the
Instructor’s Manual and Test Bank. And most importantly, we are grateful to
Dennis and Richard for their support and understanding through the long days
and busy phone lines.
The Authors
We have had fun teaching and writing about Visual Basic. We hope that this
feeling is evident as you read this book and that you will enjoy learning or
teaching this outstanding programming language.
Julia Case Bradley
Anita C. Millspaugh
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xiii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
20. The best way to learn to program in Visual Basic is to do it. If you enter and run
the sample projects, you will be on your way to writing applications. Reading
the examples without trying to run them is like trying to learn a foreign lan-
guage or mathematics by just reading about it. Enter the projects, look up your
questions in the extensive MSDN Help files, and make those projects run.
Installing Visual Basic
For the programs in this text, you need to install the .NET Framework, Visual
Basic, and the MSDN (Microsoft Developers Network) library, which contains
all of Help and many instructive articles. You do not need to install C++ or C#.
You can download the Express Edition of Visual Basic and Visual Web
Developer from msdn.microsoft.com/express. Using these two products, you
can complete most of the exercises in this text.
Format Used for Visual Basic
Statements
Visual Basic statements, methods, and functions are shown in this font. Any
values that you must supply are in italics. Optional items are in [square
brackets]. Braces and a vertical bar indicate that you must choose one or the
other value {one | other}.
Examples
Const Identifier [As Datatype] = Value
Do {While | Until} Condition
As you work your way through this textbook, note that you may see a sub-
set of the available options for a Visual Basic statement or method. Generally,
the options that are included reflect those covered in the chapter. If you want to
see the complete format for any statement or all versions of a method, refer to
Help.
J.C.B.
A.C.M.
xv
TO THE STUDENT
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xv ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
22. Julia Bradley is a professor emeritus of Computer Information Systems at Mt. San
Antonio College. She developed and taught computer programming courses for 25
years and then took early retirement from teaching in order to write full time. Most
recently she has taught courses in introductory and advanced Visual Basic, Access
programming, and Microsoft Office. She began writing BASIC textbooks in 1984
using MS-BASIC (GW-BASIC) and has authored or co-authored texts in Macintosh
Basic, QuickBasic, QBasic, Visual Basic, C#, Java, the Internet, and desktop
publishing.
Anita Millspaugh teaches programming courses in Visual Basic, C#, and Java at
Mt. San Antonio College and has served as chair of the department for eight years.
She received her MBA from California State Polytechnic University, with a bache-
lor’s degree in Computer Information Systems. She has taught faculty at the Na-
tional Computer Educator’s Institute and also has led Great Teacher’s Conferences
for Mt. SAC and for California Vocational Faculty.
xvii
About the Authors
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xvii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
24. Chapter 1
Introduction to Visual Basic
2008 1
Chapter 2
User Interface Design 67
Chapter 3
Variables, Constants, and
Calculations 109
Chapter 4
Decisions and Conditions 159
Chapter 5
Menus, Common Dialog Boxes,
Sub Procedures, and Function
Procedures 213
Chapter 6
Multiform Projects 253
Chapter 7
Lists, Loops, and Printing 287
Chapter 8
Arrays 329
Chapter 9
Web Applications 361
Chapter 10
Database Applications 401
Chapter 11
Data Files 439
Chapter 12
OOP: Creating Object-Oriented
Programs 469
Chapter 13
Graphics, Animation, Sound, and
Drag-and-Drop 525
Chapter 14
Additional Topics in Visual
Basic 561
Appendix A
Answers to Feedback
Questions 607
Appendix B
Methods and Functions for
Working with Dates, Financial
Calculations, Mathematics, and
String Operations 621
Appendix C
Tips and Shortcuts for Mastering
the Environment 635
Appendix D
Security 647
Glossary 651
Index 662
xix
BRIEF CONTENTS
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xix ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
26. 2
1
Introduction to
Visual Basic
2008 1
Writing Windows Applications
with Visual Basic 2
The Windows Graphical User
Interface 3
Programming Languages—
Procedural, Event Driven,
and Object Oriented 3
The Object Model 4
Microsoft’s Visual Studio 5
Writing Visual Basic Projects 6
The Three-Step Process 6
Visual Basic Application Files 7
The Visual Studio
Environment 8
Default Environment Settings 8
The IDE Initial Screen 9
The New Project Dialog 9
The IDE Main Window 11
The Toolbars 12
The Document Window 12
The Form Designer 13
The Solution Explorer Window 13
The Properties Window 13
The Toolbox 13
Help 13
Design Time, Run Time,
and Debug Time 14
Writing Your First
Visual Basic Project 14
Set Up Your Workspace 14
Plan the Project 18
Define the User Interface 19
Set Properties 23
Write Code 29
Visual Basic Code Statements 30
Code the Event Procedures
for Hello World 32
Run the Project 35
Save Your Work 36
Open the Project 37
Modify the Project 38
Print the Code 45
A Sample Printout 45
Finding and Fixing Errors 46
Syntax Errors 46
Run-Time Errors 49
Logic Errors 49
Project Debugging 50
Naming Rules and Conventions
for Objects 50
Visual Studio Help 51
Installing and Running MSDN 52
Viewing Help Topics 52
Context-Sensitive Help 55
Managing Windows 55
Your Hands-On
Programming Example 56
User Interface
Design 67
Introducing More Controls 68
Text Boxes 69
Masked Text Boxes 70
Rich Text Boxes 71
Displaying Text on Multiple
Lines 71
Group Boxes 72
Check Boxes 73
Radio Buttons 73
Picture Boxes 73
Using Smart Tags 76
Using Images for Forms and
Controls 77
Setting a Border and Style 77
Drawing a Line 77
Working with Multiple
Controls 78
Selecting Multiple Controls 78
Deselecting a Group of Controls 79
Moving Controls as a Group 79
Setting Properties for Multiple
Controls 79
Aligning Controls 80
xxi
CONTENTS
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxi ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
27. 4
3
Designing Your Applications
for User Convenience 80
Designing the User Interface 80
Defining Keyboard Access Keys 81
Setting the Accept and Cancel
Buttons 82
Setting the Tab Order for Controls 82
Setting the Form’s Location on
the Screen 84
Creating ToolTips 85
Coding for the Controls 87
Clearing Text Boxes and
Labels 87
Resetting the Focus 87
Setting the Checked
Property of Radio Buttons
and Check Boxes 88
Setting Visibility at Run Time 88
Disabling Controls 89
Setting Properties Based on
User Actions 89
Changing the Color of Text 90
Using Radio Buttons for
Selecting Colors 90
Changing Multiple Properties
of a Control 92
Concatenating Text 93
Continuing Long
Program Lines 93
Downloading and Using the
Line and Shape Controls 93
Your Hands-On Programming
Example 95
Good Programming Habits 100
Variables,
Constants, and
Calculations 109
Data—Variables and Constants110
Data Types 111
Naming Rules 112
Naming Conventions 112
Constants: Named and Intrinsic 113
Declaring Variables 115
Scope and Lifetime of Variables 117
Calculations 120
Converting Strings to a
Numeric Data Type 120
Arithmetic Operations 122
Order of Operations 123
Using Calculations in Code 124
Option Explicit and
Option Strict 125
Converting between Numeric
Data Types 127
Performing Calculations with
Unlike Data Types 128
Rounding Numbers 129
Formatting Data for Display 130
Using Format Specifier Codes 130
Choosing the Controls for
Program Output 132
A Calculation Programming
Example 133
Planning the Project 133
The Project Coding Solution 136
Handling Exceptions 137
Try/Catch Blocks 138
Displaying Messages in
Message Boxes 140
The TextMessage String 141
The Titlebar Text 141
MessageBoxButtons 141
MessageBoxIcon 141
Using Overloaded Methods 141
Testing Multiple Fields 143
Counting and Accumulating
Sums 144
Summing Numbers 145
Counting 145
Calculating an Average 145
Your Hands-On Programming
Example 145
Decisions and
Conditions 159
If Statements 160
Charting If Statements 162
The Helpful Editor 162
Boolean Expressions 163
Comparing Numeric Variables
and Constants 163
Comparing Strings 164
Testing for True or False 166
Comparing Uppercase and
Lowercase Characters 166
Compound Boolean Expression 167
Short-Circuit Operations 169
xxii C O N T E N T S
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
28. 6
5
Nested If Statements 169
Using If Statements with Radio
Buttons and Check Boxes 172
A “Simple Sample” 174
Checking the State of a
Radio Button Group 174
Checking the State of
Multiple Check Boxes 175
Enhancing Message Boxes 175
Displaying the Message String 175
Displaying Multiple Buttons 177
Input Validation 179
Checking for a Range of Values 179
Checking for a Required Field 179
Performing Multiple
Validations 180
The Case Structure 181
Sharing an Event Procedure 183
Calling Event Procedures 185
Your Hands-On Programming
Example 187
Debugging Visual Basic
Projects 193
Writing Debug Output 194
Pausing Execution with the
Break All Button 195
Forcing a Break 195
Checking the Current Values
of Expressions 196
Stepping through Code 196
The Locals Window 198
The Autos Window 198
Debugging Step-by-Step
Tutorial 199
Menus, Common
Dialog Boxes,
Sub Procedures,
and Function
Procedures 213
Menus 214
Defining Menus 214
Creating a Menu—
Step-by-Step 219
Coding for Menu Items 220
Standards for Windows Menus 222
Common Dialog Boxes 223
Displaying a Windows Common
Dialog Box 223
Using the Information from the
Dialog Box 224
Setting Initial Values 226
Creating Context Menus 226
Creating a Context Menu—
Step-by-Step 227
Sharing Procedures 228
Writing General
Procedures 229
Creating a New Sub Procedure 229
Passing Arguments to
Procedures 230
Writing Function Procedures 231
Functions with Multiple
Parameters 234
Breaking Calculations into
Smaller Units 235
Basing a New Project on an
Existing Project 237
Your Hands-On Programming
Example 238
Multiform
Projects 253
Using Multiple Forms 254
Creating New Forms 254
Adding and Removing Forms 256
An About Box 257
Using the About Box Template 257
Setting Assembly Information 257
A Splash Screen 260
Using the Splash Screen
Template 260
Making the Splash Form
Display First 261
Other Template Forms 262
Using the Methods and Events
of Forms 262
Showing a Form 262
Hiding or Closing a Form 263
Responding to Form Events 264
The Sequence of Form Events 264
Writing Event Procedures for
Selected Events 264
Holding the Splash Screen
Display 267
C O N T E N T S xxiii
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxiii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
29. 7
8
Variables and Constants in
Multiform Projects 267
Scope 267
Access Level 268
Lifetime 268
Namespaces 269
Declaration Summary for
Variables and Constants 270
Guidelines for Declaring
Variables and Constants 270
Running Your Program Outside
the IDE 271
Your Hands-On Programming
Example 272
Lists, Loops, and
Printing 287
List Boxes and Combo
Boxes 288
The Items Collection 289
Filling a List 289
The SelectedIndex Property 292
The Items.Count Property 292
Referencing the Items
Collection 292
Removing an Item from a List 293
Clearing a List 294
List Box and Combo Box
Events 295
Do/Loops 296
The Boolean Data Type
Revisited 298
Using a Do/Loop with a
List Box 298
For/Next Loops 299
Negative Increment or
Counting Backward 301
Conditions Satisfied before
Entry 301
Altering the Values of the
Loop Control Variables 301
Endless Loops 302
Exiting Loops 302
Skipping to the Next Iteration
of a Loop 303
Making Entries Appear
Selected 304
Selecting the Entry in a
Text Box 304
Selecting an Entry in a List
Box 305
Sending Information to
the Printer 305
The PrintDocument Component 306
Getting Started with Printing—
Step-by-Step 308
Printing Summary 310
Printing the Contents of a
List Box 310
Printing the Selected Item
from a List 310
Aligning Decimal Columns 310
Displaying a Print Preview 311
Adding a PrintPreview Dialog
to the Print Project—
Step-by-Step 312
The Using Block 313
Printing Multiple Pages 313
Your Hands-On Programming
Example 314
Arrays 329
Single-Dimension Arrays 330
Subscripts 330
Valid Subscripts 331
For Each/Next Statements 332
Structures 333
Declaring Variables Based on
a Structure 334
Accessing the Elements in a
Structure Variable 334
Including an Array in a
Structure 334
Using Array Elements for
Accumulators 335
Adding to the Correct Total 335
Debugging Array Programs 337
Table Lookup 337
Coding a Table Lookup 338
Using List Boxes with Arrays 340
Multidimensional Arrays 341
Initializing Two-Dimensional
Arrays 343
Printing a Two-Dimensional
Table 343
Summing a Two-Dimensional
Table 344
Lookup Operation for
Two-Dimensional Tables 345
Your Hands-On Programming
Example 347
xxiv C O N T E N T S
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxiv ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
30. 11
10
9
Web Applications 361
Visual Basic and Web
Programming 362
Client/Server Web Applications 362
Types of Web Sites 364
File System Web Sites 364
IIS Web Sites 364
Remote Sites and FTP Sites 365
Creating a Web Site 365
Web Page Files 365
Web Forms in the
Visual Studio IDE 366
Creating Your First
Web Form—Step-by-Step 367
Viewing the HTML Code 369
Controls 369
Event Handling 370
Files 371
Debugging 371
Testing in Other Browsers 372
Laying Out Web Forms 373
Using Tables for Layout 373
Absolute Positioning 375
Including Images on
Web Pages 376
Cascading Style Sheets 378
Navigating Web Pages 383
Using Hyperlinks 383
Adding a Second Web Page 383
Using the Validator Controls 385
Maintaining State 386
Retaining the Contents
of Controls 386
Retaining the Values of
Variables 387
AJAX 388
Managing Web Projects 389
Using the Copy Web Site Tool 390
Some Web Acronyms 390
Your Hands-On Programming
Example 390
Database
Applications 401
Databases 402
Visual Basic and Databases 402
Database Terminology 402
XML Data 403
Using ADO.NET and
Visual Basic 404
Data Access in
Visual Studio 405
Binding Sources 406
Table Adapters 406
Datasets 406
Creating a Database
Application 407
A Windows Database
Application—Step-by-Step 407
The Smart Tag 412
The Database Schema File 412
Binding Individual
Data Fields 413
The Data Sources Window 413
Database Details
Program—Step-by-Step 415
Selecting Records from
a List 417
Converting to Combo Box
Selection—Step-by-Step 417
Selecting Fields from the Table 420
Sorting the List Data 421
Choosing the Control Type
for Fields 421
Selecting Records Using
Web Forms 423
Security in Web Database
Applications 424
Creating the Web Selection
Application—Step-by-Step 424
LINQ 431
Querying Operating
System Data 431
Creating a LINQ Project—
Step-by-Step 431
A FileSystem LINQ Example 432
Your Hands-On Programming
Example 434
Data Files 439
Data Files 440
Simple VB File I/O 440
Writing and Reading
Text Files 441
C O N T E N T S xxv
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxv ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
31. 12
13
Writing and Reading
Delimited Files 441
.NET File Handling 447
File Handling Using Streams 447
Writing Data in a File Using a
StreamWriter 447
Reading Data from a File
Using a StreamReader 449
Using the File Common
Dialog Box 452
OpenFileDialog Component
Properties 452
Displaying the Open File
Dialog Box 453
The Open and Write File
Program 455
Saving the Contents
of a List Box 456
Loading the List Box 457
Checking for Existence
of the File 457
Saving the File 458
Querying the User to Save 459
The FormClosing Event
Procedure 459
XML Files 460
Your Hands-On Programming
Example 460
OOP: Creating
Object-Oriented
Programs 469
Object-Oriented
Programming 470
Objects 470
Object-Oriented Terminology 471
Reusable Classes 473
Multitier Applications 473
Classes 474
Designing Your Own Class 474
Creating Properties in a
Class 475
Class Methods 476
Constructors and
Destructors 477
Creating a New Class—
Step-by-Step 478
Property Procedures with
Mixed Access Levels 483
Creating a New Object
Using a Class 484
Defining and Using a New
Object—Step-by-Step 485
Instance Variables versus
Shared Variables 487
Adding Shared Properties to
the Step-by-Step Exercise 489
Destructors 490
Garbage Collection 491
Inheritance 491
Inheriting Properties
and Methods 491
Constructors in Inheritance 491
Overriding Methods 492
Accessing Properties 493
Creating a Derived Class
Based on BookSale 493
Adding Inheritance to the
Step-by-Step Exercise 494
Creating a Base Class Strictly
for Inheritance 497
Inheriting Form Classes 497
Passing Properties between
Forms 501
Passing Values to a Summary
Form 501
Passing Objects as Properties 503
Managing Multiclass
Projects 504
Adding an Existing Class File
to a Project 504
Using the Object Browser 504
Examining VB Classes 506
Examining Your Own Classes 507
Your Hands-On Programming
Example 507
Graphics,
Animation,
Sound, and
Drag-and-Drop 525
Graphics in Windows and
the Web 526
The Graphics Environment 526
Steps for Drawing Graphics 526
The Paint Event Procedure 527
Pen and Brush Objects 527
The Coordinate System 529
Graphics Methods 530
xxvi C O N T E N T S
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxvi ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
32. A
B
14
Random Numbers 532
Simple Animation 534
Displaying an Animated
Graphic 534
Controlling Pictures at
Run Time 534
Moving a Picture 537
The Timer Component 537
The Scroll Bar Controls 539
Scroll Bar Properties 539
Scroll Bar Events 541
A Programming Example 541
Playing Sounds 543
Adding Sound Files to the
Resources for a Project 543
A Sound-Playing Program 543
Playing Videos 545
Using the Windows Media
Player Control 545
Drag-and-Drop Programming 547
The Source Object 547
The Target Object 548
The Drag-and-Drop Program 549
Dragging and Dropping an
Image 550
Your Hands-On Programming
Example 552
Additional Topics
in Visual Basic 561
Advanced Validation
Techniques 562
The ErrorProvider Component 562
The MaxLength and
CharacterCasing Properties 565
Field-Level Validation 566
Capturing Keystrokes
from the User 569
Using the Masked Text Box
for Validation 570
Code Snippets and Samples 570
Code Snippets 570
Sample Projects 571
Multiple Document Interface 571
Creating an MDI Project 572
Adding a Window Menu 573
Toolbars and Status Bars 575
Toolbars 575
Status Bars 577
Some Helpful Date Controls 578
The Calendar Controls 578
Displaying Web Pages on a
Windows Form 581
The WebBrowser Control 581
A WebBrowser Program 582
Checking for the Enter Key 583
XML Data Files 584
Nodes, Elements, and Attributes 584
VB Tools for Reading XML Files 585
Writing and Reading an
XML File 591
Windows Presentation
Foundation (WPF) 593
WPF Interoperability 593
Adding a WPF Control to a
Windows Form—Step-by-Step 597
Writing a WPF Application 597
Creating a WPF Hello World
Application—Step-by-Step 599
The Role of Expression Blend 601
Answers to
Feedback
Questions 607
Methods and
Functions for
Working with Dates,
Financial
Calculations,
Mathematics, and
String Operations621
Working with Dates 622
The DateTime Structure 622
Retrieving the System
Date and Time 623
Date Variables 624
Converting Values to a
Date Format 625
Finding the Difference
between Dates 625
Checking for the Day
of the Week 625
Financial Functions 626
The Pmt Function 626
The Rate Function 627
Functions to Calculate
Depreciation 628
C O N T E N T S xxvii
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxvii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
33. xxviii C O N T E N T S
C D
Mathematical Functions 628
Working with Strings 630
Methods for Conversion
between Data Types 632
Functions for Checking
Validity 633
Functions for Formatting
Output 634
Tips and Shortcuts
for Mastering the
Environment 635
Set Up the Screen for Your
Convenience 636
Close or Hide Extra Windows 636
Use the Full Screen 638
Modify the Screen Layout 639
Split the Screen Vertically 640
Reset the IDE Layout 640
Set Options for Your Work 640
Use Shortcuts in the Form
Designer 641
Use the Layout Toolbar 641
Nudge Controls into Place 641
Use Snap Lines to Help Align
Controls 641
Use Shortcuts in the Editor 642
Use the Text Editor Toolbar 643
Use Keyboard Shortcuts When
Editing Code 643
Split the Editor Window 644
Use Drag-and-Drop Editing 645
Drag Commonly Used Code to
the Toolbox 645
Rename Variables and Objects 645
Use Context-Sensitive Help 645
Copy and Move Projects 646
Copy and Move a Project 646
Deploy Applications 646
Security 647
Authentication and
Authorization 648
Authorization and
Impersonation 648
Writing Secure Code 649
SQL Injection 649
Error Messages 649
Code Access Security 649
Glossary 651
Index 662
bra17208_fm_i-xxviii 4/11/08 9:18PM Page xxviii ntt MHBR:MH-BURR:MHBR023:MHBR023-FM:
34. Try
' Convert quantity to numeric variable.
QuantityInteger = Integer.Parse(QuantityTex
Try
' Convert price if quantity was successf
PriceDecimal = Decimal.Parse(PriceTextBo
' Calculate values for sale.
ExtendedPriceDecimal = QuantityInteger *
DiscountDecimal = Decimal.Round((Extende
DiscountedPriceDecimal = ExtendedPriceDe
' Calculate summary values.
QuantitySumInteger += QuantityInteger
DiscountSumDecimal += DiscountDecimal
DiscountedPriceSumDecimal += DiscountedP
SaleCountInteger += 1
AverageDiscountDecimal = DiscountSumDeci
C H A P T E R
1
Introduction to Visual
Basic 2008
at the completion of this chapter, you will be able to . . .
1. Describe the process of visual program design and development.
2. Explain the term object-oriented programming.
3. Explain the concepts of classes, objects, properties, methods, and
events.
4. List and describe the three steps for writing a Visual Basic project.
5. Describe the various files that make up a Visual Basic project.
6. Identify the elements in the Visual Studio environment.
7. Define design time, run time, and debug time.
8. Write, run, save, print, and modify your first Visual Basic project.
9. Identify syntax errors, run-time errors, and logic errors.
10. Use AutoCorrect to correct syntax errors.
11. Look up Visual Basic topics in Help.
bra17208_ch01_001-066 3/20/08 5:08AM Page 1 ntt Os9:Desktop Folder:TEMPWORK:March 08:19/03/08:MHBR023/bradly/night:
35. 2 V I S U A L B A S I C Introduction to Visual Basic 2008
Writing Windows Applications with Visual Basic
Using this text, you will learn to write computer programs that run in the Mi-
crosoft Windows environment. Your projects will look and act like standard
Windows programs. You will use the tools in Visual Basic (VB) and Windows
Forms to create windows with familiar elements such as labels, text boxes, but-
tons, radio buttons, check boxes, list boxes, menus, and scroll bars. Figure 1.1
shows some sample Windows user interfaces.
Beginning in Chapter 9, you will create programs using Web Forms and
Visual Web Developer. You can run Web applications in a browser such as
Text boxes
Buttons
Picture
box
Labels
Radio
buttons
Labels
Check box
F i g u r e 1 . 1
Graphical user interfaces for
application programs designed
with Visual Basic and
Windows Forms.
Group box
List box
Drop-down list
Menu bar
Internet Explorer or Mozilla FireFox, on the Internet, or on a company intranet.
Figure 1.2 shows a Web Form application.
You also will become acquainted with Microsoft’s new screen design tech-
nology, Windows Presentation Foundation (WPF), which is covered in Chapter 14.
WPF uses its own designer and design elements, which are different from those
used for Windows forms.
bra17208_ch01_001-066 4/2/08 7:20PM Page 2 ntt Os9:Desktop Folder:MHBR023-MICS:
36. C H A P T E R 1 3
The Windows Graphical User Interface
Microsoft Windows uses a graphical user interface, or GUI (pronounced
“gooey”). The Windows GUI defines how the various elements look and function.
As a Visual Basic programmer, you have available a toolbox of these elements.
You will create new windows, called forms. Then you will use the toolbox to add
the various elements, called controls. The projects that you will write follow a
programming technique called object-oriented programming (OOP).
F i g u r e 1 . 2
A Web Form application created
with Visual Web Developer,
running in a browser.
Programming Languages—Procedural, Event Driven,
and Object Oriented
There are literally hundreds of programming languages. Each was developed to
solve a particular type of problem. Most traditional languages, such as BASIC,
C, COBOL, FORTRAN, PL/I, and Pascal, are considered procedural lan-
guages. That is, the program specifies the exact sequence of all operations. Pro-
gram logic determines the next instruction to execute in response to conditions
and user requests.
The newer programming languages, such as Visual Basic, C#, and Java, use
a different approach: object-oriented programming. As a stepping stone between
procedural programming and object-oriented programming, the early versions of
Visual Basic provided many (but not all) elements of an object-oriented language.
For that reason, Microsoft referred to Visual Basic (version 6 and earlier) as an
event-driven programming language rather than an object-oriented language. But
with Visual Studio, which includes Visual Basic, C#, and F#, we have pro-
gramming languages that are truly object oriented. (Another language, C++, has
elements of OOP and of procedural programming and doesn’t conform fully to ei-
ther paradigm.) F#, introduced in 2007, applies the object-oriented paradigm to
scripting languages for cross-platform development.
bra17208_ch01_001-066 3/18/08 1:21AM Page 3 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
37. 4 V I S U A L B A S I C Introduction to Visual Basic 2008
In the OOP model, programs are no longer procedural. They do not follow
a sequential logic. You, as the programmer, do not take control and determine
the sequence of execution. Instead, the user can press keys and click various
buttons and boxes in a window. Each user action can cause an event to occur,
which triggers a Basic procedure that you have written. For example, the user
clicks on a button labeled Calculate. The clicking causes the button’s Click
event to occur, and the program automatically jumps to a procedure you have
written to do the calculation.
The Object Model
In Visual Basic you will work with objects, which have properties, methods,
and events. Each object is based on a class.
Objects
Think of an object as a thing, or a noun. Examples of objects are forms and con-
trols. Forms are the windows and dialog boxes you place on the screen; controls
are the components you place inside a form, such as text boxes, buttons, and
list boxes.
Properties
Properties tell something about or control the behavior of an object, such as its
name, color, size, or location. You can think of properties as adjectives that de-
scribe objects.
When you refer to a property, you first name the object, add a period, and
then name the property. For example, refer to the Text property of a form called
SalesForm as SalesForm.Text (pronounced “sales form dot text”).
Methods
Actions associated with objects are called methods. Methods are the verbs of
object-oriented programming. Some typical methods are Close, Show, and
Clear. Each of the predefined objects has a set of methods that you can use.
You will learn to write additional methods to perform actions in your programs.
You refer to methods as Object.Method (“object dot method”). For exam-
ple, a Show method can apply to different objects: BillingForm.Show shows
the form object called BillingForm; ExitButton.Show shows the button object
called ExitButton.
Events
You can write procedures that execute when a particular event occurs. An event
occurs when the user takes an action, such as clicking a button, pressing a key,
scrolling, or closing a window. Events also can be triggered by actions of other
objects, such as repainting a form or a timer reaching a preset point.
Classes
A class is a template or blueprint used to create a new object. Classes contain
the definition of all available properties, methods, and events.
Each time that you create a new object, it must be based on a class. For ex-
ample, you may decide to place three buttons on your form. Each button is based
on the Button class and is considered one object, called an instance of the class.
Each button (or instance) has its own set of properties, methods, and events. One
The term members is used to refer to
both properties and methods. ■
TIP
bra17208_ch01_001-066 3/18/08 1:21AM Page 4 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
38. C H A P T E R 1 5
button may be labeled “OK”, one “Cancel”, and one “Exit”. When the user
clicks the OK button, that button’s Click event occurs; if the user clicks on the
Exit button, that button’s Click event occurs. And, of course, you have written
different program instructions for each of the buttons’ Click events.
An Analogy
If the concepts of classes, objects, properties, methods, and events are still a
little unclear, maybe an analogy will help. Consider an Automobile class.
When we say automobile, we are not referring to a particular auto, but we know
that an automobile has a make and model, a color, an engine, and a number of
doors. These elements are the properties of the Automobile class.
Each individual auto is an object, or an instance of the Automobile class.
Each Automobile object has its own settings for the available properties. For
example, each object has a Color property, such as MyAuto.Color Blue and
YourAuto.Color Red.
The methods, or actions, of the Automobile class might be Start,
SpeedUp, SlowDown, and Stop. To refer to the methods of a specific object of
the class, use MyAuto.Start and YourAuto.Stop.
The events of an Automobile class could be Arrive or Crash. In a VB pro-
gram you write procedures that specify the actions you want to take when a par-
ticular event occurs for an object. For example, you might write a procedure for
the YourAuto.Crash event.
Note: Chapter 12 presents object-oriented programming in greater depth.
Microsoft’s Visual Studio
The latest version of Microsoft’s Visual Studio, called Visual Studio 2008,
includes Visual Basic, Visual C++, Visual C# (C sharp), and the .NET 3.5
Framework.
The .NET Framework
The programming languages in Visual Studio run in the .NET Framework. The
Framework provides for easier development of Web-based and Windows-based
applications, allows objects from different languages to operate together, and
standardizes how the languages refer to data and objects. Several third-party
vendors have announced or have released versions of other programming lan-
guages to run in the .NET Framework, including .NET versions of APL by Dya-
log, FORTRAN by Lahey Computer Systems, COBOL by Fujitsu Software
Corporation, Pascal by the Queensland University of Technology (free), PERL
by ActiveState, RPG by ASNA, and Java, known as IKVM.NET.
The .NET languages all compile to (are translated to) a common machine
language, called Microsoft Intermediate Language (MSIL). The MSIL code,
called managed code, runs in the Common Language Runtime (CLR), which is
part of the .NET Framework.
Visual Basic
Microsoft Visual Basic comes with Visual Studio. You also can purchase VB
by itself (without the other languages but with the .NET Framework). VB
is available in an Express Edition, a Standard Edition, a Professional
Edition, and a Team System Edition. Anyone planning to do professional
bra17208_ch01_001-066 3/18/08 1:21AM Page 5 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
39. 6 V I S U A L B A S I C Introduction to Visual Basic 2008
application development that includes the advanced features of database man-
agement should use the Professional Edition or the Team System Edition. You
can find a matrix showing the features of each edition in Help. The Profes-
sional Edition is available to educational institutions through the Microsoft
Academic Alliance program and is the best possible deal. When a campus de-
partment purchases the Academic Alliance, the school can install Visual Stu-
dio on all classroom and lab computers and provide the software to all
students and faculty at no additional charge.
Microsoft provides an Express Edition of each of the programming
languages, which you can download for free (www.microsoft.com/express/
download/). You can use Visual Basic Express for Windows development and
Visual Web Developer Express for the Web applications in Chapter 9. This text
is based on the Professional Edition of Visual Studio 2008. However, you can do
the projects using Visual Basic 2008 Express Edition and Visual Web Developer
2008 Express Edition, all of which are the current versions. This version of Visual
Basic is called both Visual Basic 2008 and Visual Basic 9. You cannot run the
projects in this text in any earlier version of VB.
Writing Visual Basic Projects
When you write a Visual Basic application, you follow a three-step process for
planning the project and then repeat the three-step process for creating the proj-
ect. The three steps involve setting up the user interface, defining the proper-
ties, and then creating the code.
The Three-Step Process
Planning
1. Design the user interface. When you plan the user interface, you
draw a sketch of the screens the user will see when running your proj-
ect. On your sketch, show the forms and all the controls that you plan
to use. Indicate the names that you plan to give the form and each of
the objects on the form. Refer to Figure 1.1 for examples of user
interfaces.
Before you proceed with any more steps, consult with your user and
make sure that you both agree on the look and feel of the project.
2. Plan the properties. For each object, write down the properties that you
plan to set or change during the design of the form.
3. Plan the Basic code. In this step, you plan the classes and procedures
that will execute when your project runs. You will determine which
events require action to be taken and then make a step-by-step plan for
those actions.
Later, when you actually write the Visual Basic code, you must fol-
low the language syntax rules. But during the planning stage, you will
write out the actions using pseudocode, which is an English expres-
sion or comment that describes the action. For example, you must plan
for the event that occurs when the user clicks on the Exit button. The
pseudocode for the event could be Terminate the project or Quit.
bra17208_ch01_001-066 3/18/08 1:21AM Page 6 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
40. C H A P T E R 1 7
Programming
After you have completed the planning steps and have approval from your user,
you are ready to begin the actual construction of the project. Use the same
three-step process that you used for planning.
1. Define the user interface. When you define the user interface, you cre-
ate the forms and controls that you designed in the planning stage.
Think of this step as defining the objects you will use in your
application.
2. Set the properties. When you set the properties of the objects, you give
each object a name and define such attributes as the contents of a label,
the size of the text, and the words that appear on top of a button and in
the form’s title bar.
You might think of this step as describing each object.
3. Write the Basic code. You will use Basic programming statements (called
Basic code) to carry out the actions needed by your program. You will be
surprised and pleased by how few statements you need to create a pow-
erful Windows program.
You can think of this third step as defining the actions of your program.
Visual Basic Application Files
A Visual Basic application, called a solution, can consist of one or more proj-
ects. Since all of the solutions in this text have only one project, you can think
of one solution one project. Each project can contain one or more form files.
In Chapters 1 through 5, all projects have only one form, so you can think of
one project one form. Starting in Chapter 6, your projects will contain mul-
tiple forms and additional files. As an example, the HelloWorld application that
you will create later in this chapter creates the following files:
File Name File Icon Description
HelloWorld.sln The solution file. A text file that holds
information about the solution and the projects
it contains. This is the primary file for the
solution—the one that you open to work on or
run your project. Note the “9” on the icon,
which refers to VB version 9.
HelloWorld.suo Solution user options file. Stores information
about the state of the integrated development
environment (IDE) so that all customizations
can be restored each time you open the
solution.
HelloForm.vb A .vb file that holds the code procedures that
you write. This is a text file that you can open
in any editor. Warning: You should not modify
this file unless you are using the editor in the
Visual Studio environment.
HelloForm.resx A resource file for the form. This text file defines
all resources used by the form, including strings
of text, numbers, and any graphics.
bra17208_ch01_001-066 3/20/08 5:08AM Page 7 ntt Os9:Desktop Folder:TEMPWORK:March 08:19/03/08:MHBR023/bradly/night:
41. 8 V I S U A L B A S I C Introduction to Visual Basic 2008
The Visual Studio Environment
The Visual Studio environment is where you create and test your projects.
A development environment, such as Visual Studio, is called an integrated
development environment (IDE). The IDE consists of various tools, includ-
ing a form designer, which allows you to visually create a form; an editor, for
entering and modifying program code; a compiler, for translating the Visual
Basic statements into the intermediate machine code; a debugger, to help
locate and correct program errors; an object browser, to view available classes,
objects, properties, methods, and events; and a Help facility.
In versions of Visual Studio prior to .NET, each language had its own IDE.
For example, to create a VB project you would use the VB IDE, and to create a
C++ project you would use the C++ IDE. But in Visual Studio, you use one IDE
to create projects in any of the supported languages.
Note that this text is based on the Express Edition of Visual Studio. If you
are using the Professional Edition, the screens differ somewhat from those that
you see.
Default Environment Settings
The full version of Visual Studio 2008 provides an option to allow the pro-
grammer to select the default profile for the IDE. The first time you open Visual
Studio, you are presented with the Choose Default Environment Settings dialog
box (Figure 1.3), where you can choose Visual Basic Development Settings.
Notice the instructions in the dialog box: you can make a different selection
later from the Tools menu.
Note: If you are using the Express Edition of Visual Basic, you won’t see
this dialog box.
File Name File Icon Description
HelloForm.Designer.vb A file created by the Form Designer that holds
the definition of the form and its controls. You
should not modify this file directly, but make
changes in the Designer and allow it to update
the file.
HelloWorld.vbproj.user The project user option file. This text file holds
IDE option settings so that the next time you
open the project, all customizations will be
restored.
Note: You can display file extensions. In Windows Vista, open the Explorer
and select Organize / Folders and Search Options, click on the View tab, and dese-
lect the check box for Hide extensions for known file types. In Windows XP, in the
My Computer Tools menu, select Folder Options and the View tab, Deselect the
check box for Hide extensions for known file types. If you do not display the ex-
tensions, you can identify the file types by their icons.
After you run your project, you will find several more files created by the sys-
tem. These include the AssemblyInfo.vb, MyApplication.myapp, MyEvents.vb,
Resources.resx, and Resources.vb. The only file that you open directly is the
.sln, or solution file.
bra17208_ch01_001-066 3/20/08 5:08AM Page 8 ntt Os9:Desktop Folder:TEMPWORK:March 08:19/03/08:MHBR023/bradly/night:
42. C H A P T E R 1 9
The IDE Initial Screen
When you open the Visual Studio IDE, you generally see an empty environ-
ment with a Start Page (Figure 1.4). However, it’s easy to customize the envi-
ronment, so you may see a different view. In the step-by-step exercise later in
this chapter, you will learn to reset the IDE layout to its default view.
The contents of the Start Page vary, depending on whether you are con-
nected to the Internet. Microsoft has added links that can be updated, so you
may find new and interesting information on the Start Page each time you
open it. To display or hide the Start Page, select View / Other Windows / Start
Page.
You can open an existing project or begin a new project using the Start
Page or the File menu.
The New Project Dialog
You will create your first Visual Basic projects by selecting File / New Project on
the menu bar or clicking Create: Project on the Start Page, either of which opens
the New Project dialog (Figure 1.5). In the New Project dialog, select Windows
F i g u r e 1 . 3
The first time you open the Visual Studio IDE, you must select the default environment settings for a Visual Basic developer.
bra17208_ch01_001-066 3/18/08 1:21AM Page 9 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
43. 10 V I S U A L B A S I C Introduction to Visual Basic 2008
F i g u r e 1 . 4
The Visual Studio IDE with the Start Page open, as it first appears in Windows Vista, without an open project.
F i g u r e 1 . 5
Begin a new VB Windows project using the Windows Forms Application template.
Select
Visual Basic
Windows
Select the Windows Forms
Application template
Enter the project name
bra17208_ch01_001-066 3/18/08 1:21AM Page 10 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
44. C H A P T E R 1 11
Forms Application if you are using the VB Express Edition. In the Professional
Edition, first select Visual Basic and Windows in the Project Types box and
Windows Application in the Templates box. You also give the project a name on
this dialog box.
The IDE Main Window
Figure 1.6 shows the Visual Studio environment’s main window and its various
child windows. Note that each window can be moved, resized, opened, closed,
and customized. Some windows have tabs that allow you to display different
contents. Your screen may not look exactly like Figure 1.6; in all likelihood you
will want to customize the placement of the various windows. The windows in
the IDE are considered either document windows or tool windows. The Designer
and Editor windows are generally displayed in tabs in the center of the screen
(the Document window), and the various tool windows are docked along the
edges and bottom of the IDE, but the locations and docking behavior are all
customizable.
The IDE main window holds the Visual Studio menu bar and the toolbars.
You can display or hide the various windows from the View menu.
F i g u r e 1 . 6
The Visual Studio environment. Each window can be moved, resized, closed, or customized.
bra17208_ch01_001-066 3/18/08 1:21AM Page 11 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
45. 12 V I S U A L B A S I C Introduction to Visual Basic 2008
The Toolbars
You can use the buttons on the toolbars as shortcuts for frequently used opera-
tions. Each button represents a command that also can be selected from a menu.
Figure 1.7a shows the toolbar buttons on the Standard toolbar for the Professional
Edition, which displays in the main window of the IDE; Figure 1.7b shows the
Layout toolbar, which is useful for designing forms in the Form Designer; and
Figure 1.7c shows the Text Editor toolbar, which contains buttons to use in the
Editor window. Select View / Toolbars to display or hide these and other toolbars.
F i g u r e 1 . 7
The Visual Studio toolbars contain buttons that are shortcuts for menu commands. You can display or hide each of the
toolbars: a. the Standard toolbar; b. the Layout toolbar; and c. the Text Editor toolbar.
O
t
h
e
r
W
i
n
d
o
w
s
O
b
j
e
c
t
B
r
o
w
s
e
r
E
r
r
o
r
L
i
s
t
T
o
o
l
b
o
x
P
r
o
p
e
r
t
i
e
s
W
i
n
d
o
w
S
o
l
u
t
i
o
n
E
x
p
l
o
r
e
r
S
t
e
p
O
u
t
S
t
e
p
O
v
e
r
S
t
e
p
I
n
t
o
B
r
e
a
k
A
l
l
S
t
a
r
t
D
e
b
u
g
g
i
n
g
S
t
o
p
D
e
b
u
g
g
i
n
g
M
o
v
e
t
o
N
e
x
t
B
o
o
k
m
a
r
k
M
o
v
e
t
o
P
r
e
v
i
o
u
s
B
o
o
k
m
a
r
k
R
e
d
o
U
n
d
o
F
i
n
d
C
o
m
m
e
n
t
O
u
t
S
e
l
e
c
t
e
d
L
i
n
e
s
U
n
c
o
m
m
e
n
t
S
e
l
e
c
t
e
d
L
i
n
e
s
P
a
s
t
e
C
o
p
y
C
u
t
S
a
v
e
A
l
l
S
a
v
e
c
u
r
r
e
n
t
f
i
l
e
A
d
d
I
t
e
m
O
p
e
n
F
i
l
e
N
e
w
W
e
b
S
i
t
e
N
e
w
P
r
o
j
e
c
t
(a)
T
a
b
O
r
d
e
r
M
e
r
g
e
C
e
l
l
s
S
e
n
d
T
o
B
a
c
k
B
r
i
n
g
T
o
F
r
o
n
t
C
e
n
t
e
r
V
e
r
t
i
c
a
l
l
y
C
e
n
t
e
r
H
o
r
i
z
o
n
t
a
l
l
y
R
e
m
o
v
e
V
e
r
t
i
c
a
l
S
p
a
c
i
n
g
D
e
c
r
e
a
s
e
V
e
r
t
i
c
a
l
S
p
a
c
i
n
g
I
n
c
r
e
a
s
e
V
e
r
t
i
c
a
l
S
p
a
c
i
n
g
M
a
k
e
V
e
r
t
i
c
a
l
S
p
a
c
i
n
g
E
q
u
a
l
R
e
m
o
v
e
H
o
r
i
z
o
n
t
a
l
S
p
a
c
i
n
g
D
e
c
r
e
a
s
e
H
o
r
i
z
o
n
t
a
l
S
p
a
c
i
n
g
I
n
c
r
e
a
s
e
H
o
r
i
z
o
n
t
a
l
S
p
a
c
i
n
g
M
a
k
e
H
o
r
i
z
o
n
t
a
l
S
p
a
c
i
n
g
E
q
u
a
l
S
i
z
e
T
o
G
r
i
d
M
a
k
e
S
a
m
e
S
i
z
e
M
a
k
e
S
a
m
e
H
e
i
g
h
t
M
a
k
e
S
a
m
e
W
i
d
t
h
A
l
i
g
n
B
o
t
t
o
m
s
A
l
i
g
n
M
i
d
d
l
e
s
A
l
i
g
n
T
o
p
s
A
l
i
g
n
R
i
g
h
t
s
A
l
i
g
n
C
e
n
t
e
r
s
A
l
i
g
n
L
e
f
t
s
A
l
i
g
n
t
o
G
r
i
d
(b)
C
l
e
a
r
B
o
o
k
m
a
r
k
s
M
o
v
e
T
o
N
e
x
t
B
o
o
k
m
a
r
k
M
o
v
e
T
o
P
r
e
v
i
o
u
s
B
o
o
k
m
a
r
k
i
n
C
u
r
r
e
n
t
F
o
l
d
e
r
M
o
v
e
T
o
N
e
x
t
B
o
o
k
m
a
r
k
i
n
C
u
r
r
e
n
t
F
o
l
d
e
r
M
o
v
e
T
o
P
r
e
v
i
o
u
s
B
o
o
k
m
a
r
k
i
n
C
u
r
r
e
n
t
D
o
c
u
m
e
n
t
M
o
v
e
T
o
N
e
x
t
B
o
o
k
m
a
r
k
i
n
C
u
r
r
e
n
t
D
o
c
u
m
e
n
t
M
o
v
e
T
o
P
r
e
v
i
o
u
s
B
o
o
k
m
a
r
k
T
o
g
g
l
e
B
o
o
k
m
a
r
k
D
i
s
p
l
a
y
W
o
r
d
C
o
m
p
l
e
t
i
o
n
D
i
s
p
l
a
y
Q
u
i
c
k
I
n
f
o
D
i
s
p
l
a
y
P
a
r
a
m
e
t
e
r
I
n
f
o
D
i
s
p
l
a
y
a
n
O
b
j
e
c
t
M
e
m
b
e
r
L
i
s
t
(c)
I
n
c
r
e
a
s
e
I
n
d
e
n
t
D
e
c
r
e
a
s
e
I
n
d
e
n
t
The Document Window
The largest window in the center of the screen is the Document window. No-
tice the tabs across the top of the window, which allow you to switch between
bra17208_ch01_001-066 4/2/08 7:20PM Page 12 ntt Os9:Desktop Folder:MHBR023-MICS:
46. C H A P T E R 1 13
open documents. The items that display in the Document window include the
Form Designer, the Code Editor, the Database Designer, and the Object Browser.
You can switch from one tab to another, or close any of the documents us-
ing its Close button.
The Form Designer
The Form Designer is where you design a form that makes up your user in-
terface. In Figure 1.6, the Form Designer for Form1 is currently displaying.
You can drag the form’s sizing handle or selection border to change the size of
the form.
When you begin a new Visual Basic Windows application, a new form is
added to the project with the default name Form1. In the step-by-step exercise
later in the chapter, you will learn to change the form’s name.
The Solution Explorer Window
The Solution Explorer window holds the filenames for the files included in
your project and a list of the classes it references. The Solution Explorer win-
dow and the Window’s title bar hold the name of your solution (.sln) file, which
is WindowsApplication1 by default unless you give it a new value in the New
Project dialog box. In Figure 1.6, the name of the solution is MyFirstProject.
The Properties Window
You use the Properties window to set the properties for the objects in your
project. See “Set Properties” later in this chapter for instructions on changing
properties.
The Toolbox
The toolbox holds the tools you use to place controls on a form. You may have
more or different tools in your toolbox, depending on the edition of Visual Basic
you are using (Express, Standard, Professional, or Team System). Figure 1.8
shows the Express Edition toolbox.
Help
Visual Studio has an extensive Help feature, which includes the Microsoft De-
veloper Network library (MSDN). You can find reference materials for Visual
Basic, C++, C#, and Visual Studio; several books; technical articles; and the
Microsoft Knowledge Base, a database of frequently asked questions and their
answers.
Help includes the entire reference manual, as well as many coding exam-
ples. See the topic “Visual Studio Help” later in this chapter for help on Help.
When you make a selection from the Help menu, the requested item ap-
pears in a new window that floats on top of the IDE window (Figure 1.9), so you
can keep both open at the same time. It’s a good idea to set the Filtered By entry
to Visual Basic or Visual Basic Express Edition, depending on the edition you are
using.
Use Ctrl Tab to switch to another
open document in the Document
window. ■
TIP
You can sort the properties in the
window either alphabetically or by
categories. Use the buttons on the
Properties window. ■
TIP
bra17208_ch01_001-066 3/18/08 1:21AM Page 13 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
47. 14 V I S U A L B A S I C Introduction to Visual Basic 2008
Design Time, Run Time, and Debug Time
Visual Basic has three distinct modes. While you are designing the user in-
terface and writing code, you are in design time. When you are testing and
running your project, you are in run time. If you get a run-time error or
pause program execution, you are in debug time. The IDE window title bar
indicates (Running) or (Debugging) to indicate that a project is no longer in
design time.
Common controls for
Windows Forms
Scroll to see more controls
F i g u r e 1 . 8
The toolbox for Visual Studio
Windows Forms. Your toolbox
may have more or fewer tools,
depending on the edition you
are using.
You can sort the tools in the toolbox:
Right-click the toolbox and select
Sort Items Alphabetically from the
context menu (the shortcut menu). ■
TIP
Writing Your First Visual Basic Project
For your first VB project, you will create a form with three controls (see Figure
1.10). This simple project will display the message “Hello World” in a label
when the user clicks the Push Me button and will terminate when the user
clicks the Exit button.
Set Up Your Workspace
Before you can begin a project, you must run the Visual Studio IDE. You also
may need to customize your workspace.
bra17208_ch01_001-066 3/18/08 1:21AM Page 14 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
48. C H A P T E R 1 15
F i g u r e 1 . 9
Help displays in a new window, independent of the Visual Studio IDE window.
Help Favorites Index Results
Help Contents
Help Index
Help Search Selected Help page
Filter
F i g u r e 1 . 1 0
The Hello World form. The
“Hello World” message will
appear in a label when the user
clicks on the Push Me button.
The label does not appear until
the button is pressed.
Run Visual Studio
These instructions assume that Visual Studio is installed in the default loca-
tion. If you are running in a classroom or lab, the program may be installed in
an alternate location, such as directly on the desktop.
bra17208_ch01_001-066 4/2/08 7:20PM Page 15 ntt Os9:Desktop Folder:MHBR023-MICS:
49. 16 V I S U A L B A S I C Introduction to Visual Basic 2008
STEP 1: Click the Windows Start button and move the mouse pointer to All
Programs.
STEP 2: Locate Microsoft Visual Basic 2008 Express Edition or Microsoft Visual
Studio 2008.
STEP 3: If a submenu appears, select Microsoft Visual Studio 2008.
Visual Studio (VS) will start and display the Start Page (refer to Fig-
ure 1.4). If you are using Visual Studio Professional Edition and this
is the first time that VS has been opened on this computer, you may
need to select Visual Basic Development Settings from the Choose
Default Environment Setting dialog box (refer to Figure 1.3).
Note: The VS IDE can be customized to not show the Start Page when it
opens.
Start a New Project
STEP 1: Select File / New Project. The New Project dialog box opens (refer to
Figure 1.5). Make sure that Visual Basic and Windows are selected for
Project types and Windows Forms Application is selected for the tem-
plate. If you are using Visual Basic Express, the dialog box differs
slightly and you don’t have to choose the language, but you can still
choose a Windows Forms Application.
STEP 2: Enter “HelloWorld” (without the quotes) for the name of the new pro-
ject (Figure 1.11) and click the OK button. The new project opens
(Figure 1.12). At this point, your project is stored in a temporary di-
rectory. You specify the location for the project later when you save it.
Note: Your screen may look significantly different from the figure since the
environment can be customized.
F i g u r e 1 . 1 1
Enter the name for the new project.
bra17208_ch01_001-066 04/03/2008 5:42 pm Page 16 pinnacle OSX:Desktop Folder:TEMPWORK:Don't Delete (Jobs):MHBR023/Bradley:
50. C H A P T E R 1 17
Set Up Your Environment
In this section, you will customize the environment. For more information on
customizing windows, floating and docking windows, and altering the location
and contents of the various windows, see Appendix C.
STEP 1: Reset the IDE’s default layout by choosing Window / Reset Window
Layout and respond Yes to the confirmation. The IDE should now
match Figure 1.12.
Note: If the Data Sources window appears on top of the Solution Explorer
window, click on the Solution Explorer tab to make it appear on top.
STEP 2: Point to the icon for the toolbox at the left of the IDE window. The
Toolbox window pops open. Notice the pushpin icon at the top of the
window (Figure 1.13); clicking this icon pins the window open rather
than allowing it to AutoHide.
STEP 3: Click the AutoHide pushpin icon for the Toolbox window; the toolbox
will remain open.
Document window
Solution Explorer
Properties window
Toolbox
F i g u r e 1 . 1 2
The Visual Studio IDE with the new HelloWorld project.
bra17208_ch01_001-066 3/18/08 1:21AM Page 17 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
51. 18 V I S U A L B A S I C Introduction to Visual Basic 2008
Plan the Project
The first step in planning is to design the user interface. Figure 1.14 shows a
sketch of the form that includes a label and two buttons. You will refer to the
sketch as you create the project.
Toolbox icon
Pushpin icon
F i g u r e 1 . 1 3
The Toolbox window.
Push Me
Exit
MessageLabel
HelloForm
PushButton
ExitButton
F i g u r e 1 . 1 4
A sketch of the HelloWorld
form for planning.
bra17208_ch01_001-066 3/18/08 1:21AM Page 18 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
52. C H A P T E R 1 19
The next two steps, planning the properties and the code, have already
been done for this first sample project. You will be given the values in the steps
that follow.
Define the User Interface
Set Up the Form
Notice that the new form in the Document window has all the standard Win-
dows features, such as a title bar, maximize and minimize buttons, and a close
button.
STEP 1: Resize the form in the Document window: Drag the handle in the
lower-right corner down and to the right (Figure 1.15).
Place Controls on the Form
You are going to place three controls on the form: a Label and two Buttons.
STEP 1: Point to the Label tool in the toolbox and click. Then move the pointer
over the form. Notice that the pointer becomes a crosshair with a big
A and the Label tool appears selected, indicating it is the active tool
(Figure 1.16).
Drag handle to enlarge form
F i g u r e 1 . 1 5
Make the form larger by
dragging its lower-right
handle diagonally. The
handles disappear as you drag
the corner of the form.
bra17208_ch01_001-066 3/18/08 1:21AM Page 19 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
53. 20 V I S U A L B A S I C Introduction to Visual Basic 2008
STEP 2: Point to a spot where you want the left edge of the label and click. The
label and its default contents (Label1) will appear (Figure 1.17).
As long as the label is selected, you can press the Delete key to
delete it, or drag it to a new location.
Crosshair pointer
Label tool is
activated
F i g u r e 1 . 1 6
When you click on the Label tool in the toolbox, the tool’s button is activated and the mouse pointer becomes a crosshair.
F i g u r e 1 . 1 7
The newly created label
appears outlined, indicating
that it is selected. Notice that
the contents of the label are set
to Label1 by default.
bra17208_ch01_001-066 3/18/08 1:21AM Page 20 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
54. C H A P T E R 1 21
You can tell that a label is selected; it has a dotted border as shown
in Figure 1.17 when the AutoSize property is True [the default] or siz-
ing handles if you set the AutoSize property to False.
STEP 3: Place a button on the form using one of two techniques: (1) You can
click on the Button tool in the toolbox, position the crosshair pointer
for one corner of the button, and drag to the diagonally opposite cor-
ner (Figure 1.18); or (2) you can drag and drop the tool from the toolbox,
which creates a button of the default size. The new button should ap-
pear selected and have resizing handles. The blue lines that appear
are called snap lines, which can help you align your controls.
While a control is selected, you can delete it or move it. If it has re-
sizing handles, you can also resize it. Refer to Table 1.1 for instruc-
tions for selecting, deleting, resizing, and moving controls. Click
outside of a control to deselect it.
Snap line
F i g u r e 1 . 1 8
Select the Button tool and
drag diagonally to create a
new Button control. The blue
snap lines help to align
controls.
Selecting, Deleting, Moving, and Resizing Controls on a Form T a b l e 1 . 1
Select a control Click on the control.
Delete a control Select the control and then press the Delete key on the keyboard.
Move a control Select the control, point inside the control (not on a handle), press
the mouse button, and drag it to a new location.
Resize a control Make sure the control is selected and has resizing handles; then
either point to one of the handles, press the mouse button, and drag
the handle; or drag the form’s bottom border to change the height or
the side border to change the width. Note that the default format for
Labels does not allow resizing.
bra17208_ch01_001-066 3/18/08 1:21AM Page 21 ntt Os9:Desktop Folder:TEMPWORK:March 08:17/03/08:MHBR023/bradly/night:
56. propre inclination, avec le commandement de sa Mestresse, de faire
de fort bons offices. Il est parent de la Royne d'Angleterre et porte le
surnom de Sommerset, et n'eût l'on sceu faire élection d'ung plus
grand ny d'ung plus noble que luy en ce royaulme, pour honnorer
l'acte; et si, est bien estimé de sa Mestresse et bien voulu de tout ce
royaulme. L'on ne luy a pas encores ordonné sa compagnie, mais,
aussytost qu'on luy en aura baillé le rolle, il m'a promis qu'il me
l'apportera, et je l'envoyeray à Vostre Majesté affin que puissiez
mieulx ordonner de sa réception et de son traictement.
Il avoit esté commandé, à deffault du Sr
Caro, à sire Jehan
Hastingues de s'aprester pour aller succéder à Mr
de Walsingam,
mais il a tant faict que, par maladye ou aultres occasions, il s'en est
excusé, dont ung homme de robe longue, nommé le docteur Dail,
lieutenant en la court de l'admiraulté, s'appreste maintenant pour y
aller. Et encores, Sire, que je me veulx bien garder de n'estre
indiscret à contrarier par trop vostre volonté sur ma demeure par
deçà, si espérè je tant d'icelle que, pour plusieurs considérations,
dont les unes appartiennent à vostre réputation, et les aultres sont
dignes de compassion vers moy, j'impètreray bientost que Vostre
Majesté me retire.
Je ne faudray de me pleindre demein à ceste princesse et à ceulx de
son conseil de l'apprest de dix ou douze navyres, lesquelz, encor
qu'ilz s'advouent au prince d'Orange, ilz monstrent néantmoins de
vouloir trajecter des hommes et des monitions à la Rochelle; ilz
n'entrent point dans les portz, mais ilz demeurent à l'ancre en la
rade et à l'abry de la coste de deçà. Quand aulx vaysseaulx que les
françoys apprestoient, ilz demeurent en suspens par commandement
de la dicte Dame, et croy bien que, si le visadmiral trouve Vostre
Majesté bien disposé sur les choses qu'il luy proposera, que tout cest
appareil yra descendre ailleurs.
J'ay monstré à Mr
le vidame de Chartres la déclaration, en forme,
que Vostre Majesté m'a envoyé, et l'article qui le concerne dans ma
lettre. Il m'a respondu que ce luy est ung singulier et souverein bien
57. d'avoir quelque tesmoignage, tant petit soit il, de vostre bonne
intention vers luy. Il trouve le terme de son retour, dans la
chandeleuse, merveilleusement brief, veu qu'il y court le danger de
sa vye et de sa conscience; mais il proteste bien qu'il ne s'arrestera
en part du monde, où il y ayt tant soit peu d'apparence qu'on y
praticque rien ny contre le service, ny contre l'intention de Vostre
Majesté; et le jeune Pardaillan monstre avoyr la mesmes volonté; car
sont les deux qui me sont venus voyr, et qui affirment bien fort qu'ilz
ne sont passés, et qu'ilz ne demeurent icy que pour la seule
occasion de fouyr à la mort.
La responce du duc d'Alve; touchant l'accord des différendz des Pays
Bas, met tant à venir que ceulx cy commancent de s'ennuyer, et de
mal espérer d'icelle, bien qu'il n'ayt encores rien refuzé de son costé,
et seulement il uze de remises sur l'attante des dépesches
d'Espaigne, mais l'on ne prend cella icy en payement.
J'ay heu, Sire, la confirmation de ce que je vous avoys cy devant
escript, que le comte de Morthon a esté subrogé régent en Escoce
par ceulx du party du Prince, et semble qu'ilz continuent encores
l'abstinence, après le VI
e
de ce moys. Je loue grandement les bonnes
résolutions qu'avez prinses sur les affères de ce pays là, desquelles,
s'il m'est possible, je donray advis à la Royne d'Escoce et à ceulx de
Lislebourg, bien qu'il y ayt très grande difficulté d'escripre
meintenant ny à elle ny à eulx. Et sur ce, etc.
Ce XXIII
e
jour de décembre 1572.
58. CCXCIIe
DÉPESCHE
—du XXV
e
jour de décembre 1572.—
(Envoyée exprès jusques à Calais par la voye du Sr Acerbo.)
Communications privées renouées, pour la première fois depuis la Saint-
Barthèlemy, par l'ambassadeur avec Leicester.—Préparatifs de départ du
comte de Worcester.
Au Roy.
Sire, ayant le comte de Lestre sceu que j'alloys hier, qui estoit l'avant
veille de Noël, à Hamptoncourt, il m'a envoyé prier qu'il m'y donnât
à dîner, comme il a faict avec beaucoup de faveur; et a monstré qu'il
ne creinct plus de trecter en privé avecques moy, ainsy que, ces
quatre moys passés, il s'estoit bien engardé de le fère. Et le comte
de Wourchester s'est trouvé en la compagnie, avec lequel j'ay devisé
de son voyage vers Vostre Majesté, et l'ay sollicité de vouloir partir
bientost, pour se rendre à Paris, incontinent après les Roys, ce qu'il a
trouvé estre ung peu bien court; néantmoins m'a promis que, sellon
le commandement que la Royne, sa Mestresse, luy en feroit, il
mettra peyne de s'y disposer. J'en ay depuis parlé à la dicte Dame,
laquelle m'a dict qu'elle eût bien voulu, premier que le dépescher,
estre advertye s'il fault qu'elle prie une des princesses, et laquelle,
de vostre court, ou bien qu'elle commète le dict comte pour tenir
pour elle, car en voudroit uzer ainsy que l'auriez plus à gré.
59. Je luy ay respondu que j'attandz de brief une responce de Voz
Majestez là dessus; qu'il ne fault pour cella laysser de faire partir le
dict sieur comte, car elle pourra, puis après, s'il en est besoin,
envoyer sa lettre et sa commission par la poste, là où il est besoing
au dict sieur comte d'aller par journées, et ainsy nous sommes
accordez qu'elle le fera partir le III
e
jour de l'an. Sur ce, etc.
Ce XXV
e
jour de décembre 1572.
60. CCXCIIIe
DÉPESCHE
—du II
e
jour de janvier 1573.—
(Envoyée exprès jusques à la court par le Sr de Vassal.)
Audience.—Bonnes dispositions d'Élisabeth, de Leicester et de Burleigh en
faveur de la France.—Mémoire. Détails de l'audience.—Assurance de la
reine qu'elle persiste dans le traité d'alliance avec le roi, et dans la
négociation relative au commerce.—Refus d'envoyer de nouveaux
ambassadeurs en Écosse, et de chasser d'Angleterre les Français
réfugiés.—Protestation d'Élisabeth qu'elle ne donnera aucun secours à
la Rochelle.—Remerciement au sujet de la communication faite sur la
négociation en France du cardinal Orsini.—Résolution de la reine
d'envoyer sans délai le comte de Worcester en France; difficulté qu'elle
fait de le charger de reprendre la négociation du mariage.
Au Roy.
Sire, de tant que, par vostre lettre du IX
e
et X
e
du passé[15]
, je me suis
trové non seulement bien respondu sur mes précédantes dépesches,
mais encores fort amplement informé de certeins poinctz bien
importans, que desirez estre de nouveau négociez avec ceste
princesse, je n'ay fally de les luy déduyre toutz par le mesmes ordre
que je les ay trouvés en vostre dicte lettre, et avec le plus de respect
et d'expression qu'il m'a esté possible, pour tout ensemble les fère
bien prendre et bien comprendre à la dicte Dame. Dont je ne les
réytèreray icy; car c'est de Vostre Majesté mesmes que j'en ay heu
la substance, et je y ay adjouxté seulement quelque forme de
61. parolles; mais je charge le présent pourteur de vous dire, Sire, ce
que la dicte Dame m'a respondu.
Il seroit long de vous racompter icy aulcunes réplicques que j'ay
estimé ne debvoir obmettre de luy fère, lesquelles elle a prinses de
bonne part; et, en me licenciant, m'a pryé que je voulusse
communicquer, avec milord trézorier et avec le comte de Lestre, des
mesmes poinctz que je luy avoys déduictz; ce que j'ay faict. Je les ay
trouvés l'ung et l'aultre bien facilles et promptz à l'entretennement
du traicté, doubteux et incerteins aulx propos du mariage; mais si
estonnez, des choses naguières passées, qu'ilz ne sçavent comme
prendre les présentes, ny comme juger de celles d'advenir. Ilz ont
voulu avoyr temps pour rapporter le tout en l'assemblée de leur
conseil et en conférer de rechef avec leur Mestresse. Sur ce, etc.
Ce II
e
jour de janvier 1573.
INSTRUCTION DES CHOSES
dont le Sr
de Vassal, suyvant la présente dépesche,
aura à informer Leurs Majestez:
Que la Royne a respondu à mes demandes, Sire, qu'elle
confesse que vous auriez occasion de vous fyer peu de
son amityé, si cognoissiez qu'elle ne se confiât de la
vostre, et pourtant qu'elle vouloit de bon cueur déposer
les escrupulles, qu'elle avoit prins de ce qui s'estoit faict,
sur l'assurance de ce que luy fesiez dire; et que je luy
estois tesmoing qu'encor qu'elle n'eût approuvé l'acte,
qu'aulmoins s'estoit elle tousjours efforcée de l'excuser
d'elle mesmes, mais ne l'avoit peu justiffier vers les siens;
qu'il n'estoit rien advenu, de son costé, qui vous deût faire
changer de volonté; et, puisqu'il vous plésoit de
persévérer au traicté, qu'elle ne s'en départiroit pour
occasion qui se peût jamais présenter;
62. Que de rechef elle commanderoit fort volontiers à ceulx de
son conseil de pourvoir aulx choses qui restoient à
accomplir des articles du dict traicté, et que l'offre de
Vostre Majesté de vouloir assoyr l'estappe aulx marchandz
angloys, aussytost qu'ilz auroient choisy leurs lieux et
places en France, avec les privilèges accordez, et
l'émologation de voz parlementz, estoit très honnorable,
mais qu'ilz refuzoient d'y entendre, parce que la peur les
tenoit encores des évènementz de dellà; néantmoins
qu'elle les en feroit de rechef exorter; et, quand bien ilz
s'y rendroient opinyastres, le reste du traicté pour cella ne
laysseroit de demeurer en sa vigueur, ny l'ancien
commerce d'estre continué;
Que, pour la paix d'Escoce, elle ne voyoit pas que de
nouveaulx ambassadeurs, encor qu'ilz fussent de plus
grande qualité que les premiers, y peussent rien advancer,
aulmoins pour le regard d'elle, qui ne sçauroit y faire ny
dire davantage que ce qu'elle y avoit desjà dict et faict, et
que le comte de Morthon, qui estoit à présent régent,
avoit offert le chasteau de St
André pour recouvrer le
chasteau de Lislebourg, et d'aultres grandes récompances
qui valoient vingt foys mieulx que le dict chasteau, mais
ceulx de dedans estoient opinyastres; et qu'elle espéroit
qu'ilz s'accorderoient à la fin par force:
Au regard de voz subjetz qui sont icy, qu'elle ne leur avoit
peu dénier refuge pour l'occasion qu'ilz y estoient passez,
et qu'il estoit en leur liberté de s'en retourner quand ilz
voudroient; néantmoins que, de les en faire exorter, cella
luy seroit imputé à cruaulté, jusqu'à ce qu'on vît que
vostre justice ozât bien exécuter la punition qu'aviez
commandé de faire des autheurs des meurtres et
séditions passées;
Mais que, de donner secours ny assistance à ceulx de la
Rochelle, elle seroit très marrye de le faire: bien avoit
63. entendu que quelques ungs des habitans estoient
descendus vers la coste de Ouest, lesquelz elle n'avoit
point veus, et s'asseuroit qu'ilz ne trouveroient en ce
royaulme chose aulcune qui leur peût servir pour
maintenir leur rébellion, s'ilz la vouloient faire; vray est
qu'elle ne pourroit, sans injure, deffendre que quelques
ungs de ses marchandz, qui y avoient leur commerce de
longtemps, et y avoient leurs biens engagés, ne l'y
continuent, non toutesfoys d'y en fère establir de
nouveau;
Qu'elle vous remercyoit grandement de ne vous estre
layssé surprendre des persuasions du cardinal Ursin, non
qu'elle ne louât bien fort que vous vous liguissiez contre le
Turcq, comme encores elle se voudroit bien obliger à une
si saincte ligue, affin de résister au commun ennemy et
adversayre du nom chrestien, lequel, s'il n'estoit réprimé,
opprimeroit quelquefoys les plus grandes puissances et les
premières authoritez, et toute la liberté de la Chrestienté;
mais que le vray moyen de luy résister seroit de mettre
toutz les princes chrestiens en bonne union, et les
différendz de la religion en accord, non de liguer contre
luy, ainsy en apparance, une partie des forces
chrestiennes, en intention de ruyner les aultres, et que, si
Vostre Majesté s'estoit à bon esciant excusée d'entendre à
telles praticques, elle estimoit que vous cognoistriez
bientost que vous auriez beaucoup faict pour vostre
réputation; qu'elle vouloit fort fermement croyre, sans y
mettre aulcun doubte, que ne layssiez de l'aymer, pour la
diversité qui estoit entre vous de la religion, car, avant que
vostre dernière amityé fût promise ny jurée, vous sçaviez
toutz deux quelle estoit la religion l'ung de l'aultre, et
qu'elle croyoit bien qu'elles estoient diverses en quelques
parolles, mais nullement contrayres en substance; dont
tout ainsy qu'elle vous réputoit prince chrestien, qui ne luy
manqueriez de vostre foy ny de vostre parolle, qu'ainsy la
64. trouveriez vous princesse fort chrestienne, qui vous
tiendroit toutes les choses qu'elle vous avoit promises et
jurées.
Et adjouxta qu'elle croyoit que Dieu, au pis aller, n'avoit
pas encores déterminé de faire que l'Angleterre ne
demeurât là où elle estoit; aulmoins ne comprenoit elle
pas qu'il eût encores mis en pouvoir de le fère à ceulx
d'entre les hommes qui, possible, le voudroient bien
entreprendre.
Et ayant la dicte Dame là dessus faict ung peu de pause,
je luy ay dict, voyant que le temps estoit court, qu'à mon
advis il y avoit de quoy louer et approuver, et de quoy plus
la remercyer en sa responce, qu'il n'y avoit lieu d'y rien
replicquer, et pourtant je la priois de passer oultre aulx
aultres choses que je luy avois dictes.
Elle a suivy qu'à son advis Vostre Majesté se contanteroit
de l'élection qu'elle avoit faicte du comte de Wourchester,
car estoit de mesmes mayson qu'elle, personnage nourry
en la court, qui avoit esté uniquement aymé du feu Roy,
son père, et lequel vous trouveriez très inclin à Vostre
Majesté et prest à faire tout ce que vous voudriez, et vous
accompaigner là où luy commanderiez, et estimoit que
vous le recepvriez et favoriseriez ainsy qu'avez tousjours
faict ceulx qu'elle vous avoit cy devant envoyez; que,
d'adjouxter à la commission, qu'elle luy donroit du
baptesme, celle du mariage, elle s'en trouvoit en quelque
perplexité, parce que son ambassadeur ne l'avoit encores
résolue des poinctz dont elle luy avoit, longtemps y a,
donné charge qu'il s'en esclarcît avec la Royne, vostre
mère; mais qu'avant le troysiesme de janvier que le dict
comte partiroit, elle pourroit avoyr receu la responce de
son ambassadeur pour luy en mettre quelque article en
son instruction, ou bien le luy envoyeroit après; et qu'elle
creignoit assez qu'encor que Voz Majestez dissent que les
65. difficultez de l'extérieur, qui estoient ez personnes, fussent
beaucoup amandées, que néantmoins celles de l'intérieur,
qui restoient ez consciences et en la religion, ne se fissent
de jour en jour plus grandes; dont voudroit de bon cueur
qu'elles fussent vuydées: car y avoit apparence, comme je
le luy avoys bien remonstré, qu'après ceste foys, l'on
réputeroit que ce ne fût plus qu'entretènement et peyne
perdue d'en parler.
66. CCXCIVe
DÉPESCHE
—du IX
e
jour de janvier 1573.—
(Envoyée exprès jusques à Calais par la voye du Sr Acerbo.)
Audience.—Nouvelles assurances d'amitié de la part de la reine.—
Conférence de l'ambassadeur avec Burleigh, le comte de Sussex, et Mr
Smith.—Préparatifs pour la Rochelle.—Mémoire. Détails de l'audience.—
Blessure du roi.—Retard apporté au départ du comte de Worcester.—
Remerciemens d'Élisabeth sur l'offre faite par la reine de Navarre de
tenir Madame en son nom sur les fonts de baptême.—Reprise de la
négociation du mariage.—Défense faite en Angleterre de préparer des
secours pour la Rochelle.
Au Roy.
Sire, il n'est possible de voyr une plus grande satisfaction que celle
que la Royne d'Angleterre a monstré de recepvoir les bons termes
d'amityé qu'il vous a pleu me commander luy tenir, et elle aussy, de
son costé, n'a layssé une seule sorte de bonnes parolles ny de
bonnes démonstrations, qu'elle n'en ayt uzé pour me tesmoigner
que très parfaictement elle vous y correspondît; chose qui seroit
longue à mettre icy, et suffira s'il vous plaist que je touche
sommèrement aulcunes responces qu'elle m'a faictes, que je joins
dans un mémoire à part.
Et après, elle m'a pryé de vouloir conférer du tout avec milord
trézorier, avec le comte de Sussex et avec Me
Smith; qui pourtant
nous sommes retirés, toutz quatre à part. Et après qu'ilz ont eu
67. paciemment escouté la déduction des principaux poinctz, ilz ont
monstré d'avoyr très bonne inclination de satisfère, en tout ce qu'ilz
pourront, à Vostre Majesté.
Les françoys qui sont icy font tousjours quelque apprest d'armes, et
le cappitayne Poyet faict faire demy cent de longues harquebuses à
fourchette, mais semble qu'il s'en veult retourner à Fleximgues, car il
parle comme ayant charge du prince d'Orange; et les aultres font
bruict d'aller à la Rochelle; néantmoins ilz n'impètrent encores de
ceste court toutes les choses qu'ilz demandent. Je les observeray et
les feray observer, ainsy que me mandez, affin de vous advertyr de
leurs déportementz. Et sur ce, etc.
Ce IX
e
jour de janvier 1573.
MÉMOIRE
des choses que la dicte Dame m'a faict entendre.
Quand à vostre blesseure[16]
, Sire, elle m'a dit que
plusieurs occasions luy faisoient réputer peu heureuse
l'année dont nous venions de sortir, mais que cest
accident seul la luy faysoit réputer du tout malheureuse,
car s'estoit imprimé que le coup d'espée n'avoit peu estre
sinon fort grand, puisque le gentilhomme tiroit à tuer le
sanglier; et que de nul présent plus précieulx pourroit
estre elle estrénée à ce nouvel an, que de l'assurance que
luy donniez que cella s'estoit passé sans dangier, dont elle
en louoit et remercyoit Dieu de bon cueur; et cella seroit
cause de quoy elle jouyroit plus à plein le grand plésir
qu'elle avoit aussy receu d'entendre que la Royne, vostre
mère, fût entièrement bien guérye de son rume: qui vous
supplioit toutz deux de croyre qu'elle ne pouvoit ouyr qu'il
vous advînt, et aulx vostres, si peu de mal qu'elle n'y
participât incontinent, avec aultant de douleur comme s'il
touchoit à elle mesmes;
68. Et, au regard de faire promptement partir le comte de
Wourchester, qu'elle vous suplioit d'excuser ung peu, s'il
n'estoit desjà en chemin, parce qu'elle l'avoit mandé venir
en poste; et il luy avoit esté besoing de renvoyer jusques
en sa mayson, qui est en Galles bien loing d'icy, pour
quérir ses gens, son équippage et aucuns de ses parans
qu'il vouloit mener en sa compagnie, mais qu'elle le feroit
partyr dans troys jours sans faillir, bien que aulcuns luy
avoient voulu dire qu'il ne seroit assuré, et que d'aultres
eussent voulu songer que messieurs de Guyse le feroient
arrester pour ravoyr la Royne d'Escoce, ce qui n'avoit esté
sans qu'elle eût monstré que non seulement elle
mesprisoit, mais qu'elle avoit en hayne toutz les advis
qu'on luy donnoit pour luy ingindrer doubte ou souspeçon
de la foy et amytié de Vostre Majesté;
Qu'elle n'avoit parolles assez expresses pour vous
remercyer aultant qu'elle debvoit, et la Royne, vostre
mère, de l'honneur et faveur que luy faysiez, et que luy
fesiez faire par la Royne de Navarre, qu'elle deignât tenir
pour elle la petite Madame, de quoy elle se santoit vous
en avoyr, et à elle, une très grande obligation, et que son
desir doncques seroit de l'en suplier; néantmoins, voyant
que l'Impératrix vouloit que son depputé mesmes tînt
pour elle, qu'elle adviseroit, avec son conseil, comme en
debvoir uzer, affin qu'il ne s'y trovât manquement ny
diversité de sa part; et ne pensoit pas, quoy que aulcuns
escruppulleux luy eussent voulu remonstrer au contrayre,
que sa conscience ny celle du comte peussent estre
intéressez que luy mesmes pour elle intervînt en ce sainct
acte; et, quand à adjouxter son nom à celluy de
l'Impératrix, pour en faire dénommer de toutz deux leur
petite fillieule, que cella luy faysoit cognoistre combien Voz
Majestez avoient soing de n'obmettre aulcune sorte
d'honneste respect que n'essayssiez de l'en gratiffier; ce
qui luy donnoit occasion d'estre pareillement respectueuse
69. vers tout ce qu'elle cognoistroit à jamais servir à vostre
grandeur et réputation:
Au regard de donner ample instruction au dict sieur comte
pour résouldre Voz Majestez du propos du mariage, qu'elle
mettroit peyne de le faire avec des conjectures,
néantmoins, dont elle seroit contreinte d'uzer, que, si Voz
Majestez luy parloient en une sorte, qu'il vous ayt à
respondre sellon celle là; et si aultrement, aultrement; veu
qu'elle n'avoit peu estre encores esclarcye par son
ambassadeur de certeins poinctz de la religion, qu'elle luy
avoit commandé d'en parler à la Royne, vostre mère,
laquelle ne luy avoit voulu respondre, sinon que, quand
elles deux se verroient, elles s'en sçauroient bien accorder
entre elles; et que, ne se parlant, à ceste heure, plus de
l'entrevue, il falloit qu'on regardât ung peu à ce poinct, ny
ne vouloit advouer, sur ce que je luy disois que
Monseigneur le Duc se pourroit contanter de ce qu'elle
avoit voulu concéder à Monsieur, frère de Vostre Majesté,
pour l'exercice de sa religion, qu'elle luy en eût voulu rien
concéder, puisque rien il n'en avoit voulu accepter, et
qu'elle se vouloit bien garder de ne se trop haster, affin de
ne broncher là où elle avoit cuydé trébucher l'aultre foys;
et que son ambassadeur se trouvoit si estonné d'avoyr
trop espéré le premier mariage, qu'encor qu'il ne desirât
pas moins ce segond, si ne trouvoit elle qu'en pas une de
ses lettres il ozât encores assurer que Voz Majestez, à bon
esciant, aient une ferme dellibération de l'effectuer;
Que ce qui s'estoit parlé, entre elle et le Sr
de Mauvissière,
de Monseigneur le Duc, qu'il pourroit faire ung voyage à la
desrobée jusques icy, que cella s'estoit dict, plus sur
l'occasion de leur propos, que non qu'elle l'eût mis en
avant elle mesmes, car avoit tousjours remis cella à ce
que Vostre Majesté et la Royne, vostre mère, jugeriez que
seroit honnorable pour luy de faire;
70. Et qu'elle vous remercyoit, le plus qu'elle pouvoit, de
l'offre que luy fesiez qu'après les difficultez vuydées et les
choses réduictes à quelque bon accord, que Voz Majestez
mettroient lors peyne de luy satisfaire, et de luy defférer,
et luy uzer beaucoup de respectz; qu'elle n'avoit garde
d'en desirer jamais de plus grandz qu'elle ne debvoit, ny
qui ne fussent égallement honnorables à Monseigneur le
Duc et à la couronne dont il est, qu'ilz le pourroient estre
à elle et à la sienne; et que, de tenir les choses en
longueur, c'estoit ce qu'elle vouloit surtout éviter, et
croyoit bien que Voz Majestez et toute la Chrestienté
jugeoient assez d'où procédoit, à ceste heure, le
retardement;
Au regard de ce que j'avois entendu que quelques ungs
armoient en ce royaulme pour nuyre à voz subjectz,
qu'elle me prioit de ne le vouloir aulcunement croire; car
c'estoit chose qu'elle avoit expressément deffendu; et
avoit mandé à toutz les gardiens de ses portz qu'ilz
missent ordre de l'empescher; dont elle me pouvoit
assurer que, des principaulx lieux et hâvres de son
royaulme, il n'en sortiroit rien, de quoy j'eusse cy après
occasion de me pleindre; mais qu'à la vérité la mer estoit
desjà si pleine de pirates, et il y avoit tant de petits lieux
et criques cachées le long de la coste de deçà, qu'elle n'y
sçauroit mettre l'ordre qu'elle vouloit; mais que ce n'estoit
que larrons de mer, lesquelz il failloit que le premier qui
les pourroit prendre les fît pendre;
Que, touchant ce que Mr
le baron de La Garde escripvoit,
de douze vaysseaulx angloys qui s'estoient esforcés
d'entrer au port de la Rochelle, et favoriser ceux qui y
portoient des vivres, qu'elle sçavoit bien la responce que
son ambassadeur avoit faicte là dessus, que, s'il y eut eu
douze bons navyres angloys, l'on ne les eût pas
légièrement empeschés d'aller là où ilz eussent voulu; et
71. cuydoit, à la vérité, que ce n'en estoient poinct;
néantmoins, puisque le dict Sr
de La Garde le mandoit, et,
sur ce qu'il se pleignoit d'aucuns aultres angloys qui, avec
mes passeportz, que je leur avoys baillé pour aller à
Bourdeaulx, s'estoient voulu couler dans la dicte ville,
qu'elle s'en feroit enquérir pour les faire toutz
rigoureusement punir, ainsy qu'elle estoit après à faire
chastier ceulx qui avoient mené des angloys à Fleximgues,
sans qu'elle l'eût ordonné; et qu'elle vous prioit prendre
ceste seurté d'elle qu'elle ne secourra en façon du monde
les dicts de la Rochelle, et que mesmes l'on luy avoit dict
que troys des habitans estoient par deçà qui proposoient
d'en admener deux navyres chargés de greins et de
vivres; mais que, s'ilz s'attandoient à cella, ilz endureroient
longtemps la feim.
Et après, la dicte Dame est venue à quelques
particullaritez que je luy avoys touchées d'une lettre que
la Royne d'Escoce m'avoit escripte, en quoy elle m'a parlé
assez aygrement.
72. CCXCVe
DÉPESCHE
—du XV
e
jour de janvier 1573.—
(Envoyée jusques à Calais par Jehan Volet.)
Départ du comte de Worcester avec charge de traiter du mariage.—
Négociation des Pays-Bas.—Mémoire. Réclamation du vidame de
Chartres et des Srs
Pardaillan et Du Plessis contre l'ordre du roi qui leur
enjoint de rentrer en France.—Disposition du comte de Montgommery à
faire sa soumission.—Nouvelles de la Rochelle; préparatifs faits
secrètement en Angleterre pour secourir cette ville.
Au Roy.
Sire, le comte de Vourchester a esté retardé jusques aujourdhui XV
e
,
qu'on a achevé de le dépescher, et, après m'estre venu dire l'adieu
en mon logis, il s'est mis incontinent sur la Tamise. Il s'en va
pourveu d'une très bonne intention vers ces deux royaulmes, et
d'une bien ample commission, ainsy qu'il m'a dict, de sa Mestresse,
pour traicter avec Voz Majestez du poinct de l'allience qui se
recherche maintenant entre vous; qui sont deux choses, lesquelles je
m'assure, Sire, qu'avec la considération des aultres bonnes et
grandes qualités siennes, vous le feront avoyr agréable.
L'on attand tousjours icy en grande dévotion la responce du duc
d'Alve sur l'accord des différandz des Pays Bas, et semble que, si elle
n'arrive dans le caresme prenant, que ceulx cy veulent prendre
quelque aultre expédiant. Je desire, de plus en plus, Sire, que faciez
73. bientost partir le Sr
de Vérac pour Escoce, car j'entendz que les deux
praticques, de mettre le Prince d'Escoce ez meins de la Royne
d'Angleterre, et le chasteau de Lislebourg ez meins du comte de
Morthon, se poursuyvent fort à l'estroict; et me vient l'on d'advertyr
que le Sr
de Quillegreu est arrivé depuis deux jours pour cest effect
en ceste ville, et qu'il se tient caché au logis de milord trézorier, son
beau frère. L'on offre de grosses sommes pour cella. J'ay escript à
ceulx du dict chasteau la bonne provision que Vostre Majesté a
ordonné pour les affères du dict pays, et qu'ilz auront bientost par
dellà de voz nouvelles, si desjà elles ne sont arrivées. Et sur ce, etc.
Ce XV
e
jour de janvier 1573.
MÉMOIRE.
Mr
le vidame de Chartres et les Srs
De Pardaillan et Du
Plessis me sont venuz faire une grande pleincte, me
remonstrantz qu'en nul temps il n'avoit esté veu qu'on eût
jamais accusé l'absance d'aulcun, qui eût voulu fouyr bien
loing pour éviter la persécution de sa religion; et qu'ilz
vous suplient très humblement que, veu qu'il estoit bien
cognu à Vostre Majesté qu'ilz n'estoient passez en ce
royaulme, lequel est maintenant de vostre alliance, sinon
pour céder à l'extrême violence qui s'exerçoit
indifféremment en France contre ceulx de leur religion, et
pour seulement deffendre, avec la fuyte, leurs vyes, affin
de n'estre veus rebelles s'ilz se joignoient avec ceulx qui
monstrent de la vouloir deffandre par les armes, qu'il fût
vostre bon plésir ne vouloyr permettre qu'ilz soient notez
du nom infamme de rébellion.
J'ay respondu que, par vostre dernière déclaration, du VII
e
de décembre, il leur estoit pourveu d'une si bonne
seureté, en leurs maysons, qu'ilz ne se pouvoient excuser
d'y retourner.
74. Ilz m'ont réplicqué qu'il y en avoit si peu que, naguyères,
l'on avoit esté bien près, à Roan et à Paris, de
recommancer une aultre émotion sur ceulx qui restoient
de leur religion, sans que la justice eût fait semblant de
s'y ozer oposer.
Sur quoy, voulantz mener les propos plus avant, non sans
quelque altération entre nous, je leur ay résoluement
déclaré que je ne me pouvois rétracter de chose que
j'eusse dicte, car c'estoit, sellon la charge que j'en avoys,
par commandement exprès de Vostre Majesté; mais, pour
ne les désespérer, je leur ay dict que je vous feroys très
volontiers entendre ce qu'ilz m'alléguoient, dont m'ont prié
de le vouloir accepter par escript, et le faire ainsy tenir à
Vostre Majesté.
Et puis le dict Sr
Vidame, à part, m'a dict que le comte de
Montgommery offroit que, si j'avois à luy faire entendre
quelque chose, en particullier, de Vostre Majesté et de la
Royne, vostre mère, ou de Messeigneurs voz frères, qu'il
viendroit parler, avec tout respect, à moy, pour ouyr voz
bons commandementz.
Je luy ay respondu que, en brief, j'attandoys une vostre
dépesche, et que, s'il y avoit quelque chose qui le
concernât, je le luy ferois incontinent sçavoyr.
Il semble que, depuis quatre jours, soit arrivé ung
vaisseau de la Rochelle, et qu'il rapporte que Mr
de La
Noue s'en est retourné sans rien fère, et que mesmes il a
esté tenu de bien court dans la ville, non sans danger de
sa personne. Et, de tant que ceulx des habitans, qui sont
icy, voyent bien que la continuelle instance, que je fay
contre eulx, leur pourroit donner quelque empeschement
en leurs affères, ilz trouvent moyen d'attitrer des
marchandz angloys, qui ont accoustumé de trafficquer des
mesmes choses qui leur sont besoing, et par ceulx là ilz
75. font leur emplète, et puis les font embarquer en lieux
escartés; de sorte qu'il est très difficille d'y trouver
remède. Et mesmes semble que la Royne d'Angleterre, ny
ceulx de son conseil ne l'y sçauroient mettre, sans y
procéder par quelque bien extraordinayre voye; ce que,
pour ne leur toucher l'affère de si près, il n'y a pas grand
apparance qu'ilz le facent, ny qu'on les en doibve trop
presser.
Néantmoins, de tant qu'il est certein qu'il coulera
tousjours d'icy quelque rafraychissement, a la desrobbée,
aux dicts de la Rochelle, il ne sera que bon que Mr
de La
Garde n'espargne pas les navyres angloys, qu'il trouvera,
qui en abuseront; pourveu qu'il garde que, soubz tel
prétexte, l'on ne traicte mal ceulx qui yront ailleurs pour
exercer leurs commerces: car il se pourroit, à la fin, peu à
peu fère une si bonne masse au port de la Rochelle,
qu'elle ozeroit bien aller rencontrer voz gallères. De quoy il
s'en faict desjà quelque bruict; et que mesmes les dicts de
la Rochelle se veulent résouldre de n'attandre pas que
l'armée de terre approche de leurs murailles, ains qu'ilz
yront se retrancher le plus loing qu'ilz pourront pour
l'arrester, mesmement, s'il ne vous vient poinct de
Suysses, comme ilz en ont quelque espérance.
Il y a des cappitaynes de mer angloys, lesquelz, ayantz
armé des navyres soubz l'espérance de la guerre qui se
feroit pour secourir ceulx de la Rochelle, ne pouvantz
maintenant obtenir congé d'y aller, veulent vendre leurs
navyres. Et ung d'entre eulx m'a faict dire qu'il vendra très
volontiers le sien à Vostre Majesté: dont, pour garder qu'il
n'en accomode les dicts de la Rochelle, ny ceulx qui s'en
pourroient servir à nuyre à voz subjectz, je luy ay mandé
que je le vous escriprois, et que je luy en feroys avoyr
bientost responce, ce qui, possible, induyra les aultres
76. d'en fère de mesmes; dont vous plerra m'en mander
vostre intention.
77. CCXCVIe
DÉPESCHE
—du XXII
e
jour de janvier 1573.—
(Envoyée exprès jusques à Calais par la voye du Sr Acerbo.)
Négociation du comte de Worcester.—Armemens faits par les protestans
pour secourir la Rochelle.—Armemens faits par la reine d'Angleterre;
doutes sur le but qu'ils peuvent avoir.—Dessein des Anglais de
s'emparer du prince d'Écosse.—Bonne disposition du conseil en faveur
de la France.
Au Roy.
Sire, puisque le comte de Worcester est maintenant devers Vostre
Majesté pour accomplir, le plus honnorablement qu'il pourra, la
charge de tenir pour la Royne, sa Mestresse, la petite Madame sur
les sainctz fontz de baptesme, il sera bon de tirer encores de sa
légation le plus d'utilité qu'il sera possible pour le bien de vos
affères; dont, s'il vous plaist, et à la Royne, vostre mère, de traiter
bien à fondz avecques luy et avec Mr
de Vualsingam du propos de
Monseigneur le Duc, il m'a fort assuré qu'il a fort ample commission
d'y entendre, et mesmes de ne partir d'auprès de Vostre Majesté, si
la négociation prent bon train, qu'il ne la voye réduicte à quelque
bonne conclusion. Par ainsy, Sire, il est expédiant de convenir avec
eulx, en propres parolles et bien expresses, du poinct de la religion,
car ilz s'attandent que Voz Majestez, premier qu'ilz s'advancent d'en
rien dire, leur en facent ouverture par quelque bonne responce sur
les précédantes propositions que le dict de Valsingam dict qu'il en a
78. desjà, de longtemps, faictes à la Royne; en quoy semble qu'elle luy
peut demander qu'il ayt à répéter ce qu'il estime luy en avoyr
proposé, et par là en attacher si bien la praticque que toutes les
difficultés s'en puissent facillement esclarcyr.
Le comte de Montgommery a esté appellé ces jours passez à la
court, où son frère, Mr
de St
Jean, qui est arrivé icy le dix huictiesme
de ce moys, l'a trouvé, lequel vous comptera tout ce qui s'est passé
entre eulx; et nonobstant que ceulx de la Rochelle ne soient
ouvertement ouyz par la Royne, ny de ceulx de son conseil, en leurs
instances, elles sont toutesfoys secrettement reçues par aulcuns
aultres qui peuvent assez, et hier est huict jours qu'il se tint ung
conseil en une mayson privée de ceste ville sur les moyenz de
pouvoir secourir la dicte ville; dont, de plusieurs propos irrésolus,
qu'on m'a rapporté y avoyr esté tenus, semble qu'il se peut colliger
ceste résolution, que, par tout le moys de febvrier, se pourront
mettre ensemble trente cinq ou quarante navyres de ceulx de
Fleximgues, et qu'il se ramassera bien, entre françoys et vualons, et
aulcuns angloys désadvouez, jusques à troys mille hommes en tout;
lesquelz de divers endroitz couleront facillement ez dicts navyres: et
qu'avec cella s'entreprendra de mettre ung rafreschissement
d'hommes et de vivres, et de monitions, dans la ville, non sans
quelque dellibération de vouloir combattre vostre armée de mer, si
l'occasion s'y présente, et, quoy que soit, de la forcer, si elle
entreprend de leur empescher le passage.
En quoy ma souspeçon devint plus grande de ce que j'ay sceu que la
Royne d'Angleterre a faict présant d'ung navyre de six centz
tonneaulx, et de deux aultres de cent cinquante tonneaulx chacun, à
son admiral, qui a donné incontinent le grand à son filz, et les deux
aultres à deux gentilshommes ses parans; et si, a baillé commission
à neuf ou à dix aultres gentilshommes, de bonne qualité, d'en armer
chacun ung, pour estre prestz dans la fin du prochein moys de
febvrier, ce que je puis bien interpréter se faire pour d'aultres
considérations, mesmement pour se pourvoyr contre le Roy
d'Espaigne; duquel ilz se sont formés une récente peur, parce qu'on
79. leur a rapporté qu'il faict préparer ung grand équippage de mer en
Biscaye pour passer luy mesmes en Flandres, et qu'ilz n'ont receu la
responce ainsy bonne, comme ilz l'attandoient, du duc d'Alve sur
l'accord de leurs différendz; ou bien qu'ilz veulent fère quelque
secours au prince d'Orange et aux habitans de Holande et
Fleximgues, desquelz ilz ont ordinayrement leurs députés avec eulx
qui, à ce qu'on dict, n'offrent rien moins que de soubmettre
volontairement les deux isles à la perpétuelle protection de la
couronne d'Angleterre, et d'y establir présentement l'authorité de
ceste princesse partout;
Ou bien que c'est pour entendre aulx choses d'Escoce, desquelles
l'on m'a confirmé que le Sr
de Quillegreu a véritablement esté troys
jours entiers en la mayson de milord trézorier aulx champs, et s'en
est retourné le XVIII
e
du présent pour parachever la praticque de
recouvrer par deçà le Prince d'Escosse, par l'entremise des
gentilshommes qui ont la garde de sa personne, et mesmement de
celluy qui entrera en quartier à ce prochein mars, y tenant la mein le
comte de Morthon. Et, pour cest effect, il emporte dix mille escus, et
y en sera employé jusques à cent mille, s'il est besoing; joinct qu'on
dict que les principaulx de la noblesse d'Escoce monstrent de se
vouloir départir de l'intelligence du dict de Morthon, et que ceulx du
chasteau de Lillebourg ont commancé de canonner dans la ville, et y
ont tué le cappitaine Hacman et ung aultre gentilhomme, parce
qu'icelluy de Morthon a prins prisonnier milord de Sethon: ce que, si
ainsy est, ceulx cy font bien leur compte que les armes se
reprendront par dellà, incontinent après le dernier de ce moys; dont
veulent estre pourveus, et vont couvrant, plus qu'ilz ne firent
onques, et dissimulant leurs dellibérations.
Néantmoins, Sire, je veulx, par plusieurs conjectures, et encores par
quelques advis, présumer que ce qui se prépare maintenant en ceste
mer estroicte tend tout au faict de la Rochelle comme à ung affère
qui est présent, et lequel tient toutz aultres affères, du costé de
deçà, en grand suspens; dont je vous suplie très humblement, Sire,
en faire advertyr Monsieur, frère de Vostre Majesté, affin qu'il y
80. pourvoye si bien qu'il ne puisse estre ny empesché ny surprins
d'aulcun accidant. Et cependant par une ouverte et franche
négociation avec les ambassadeurs de ceste princesse, Voz Majestez
pourront essayer de remédier à ces choses, ou aulmoins de les
divertir, affin qu'elles ne puissent empescher l'heur de voz affères, ny
retarder la victoire de Mon dict Seigneur; ce que j'estime ne sera
trop difficille à conduyre, car milord trézorier m'a mandé que, si le
comte de Worcester trouve que vous soyez ainsy bien disposez,
devers ceste princesse, comme je me suis efforcé de le leur
persuader, qu'il ne fault doubter que les choses n'aillent aussy bien,
entre Voz Majestez et vos deux couronnes et subjectz, comme vous
le pourriez desirer. Sur ce, etc. Ce XXII
e
jour de janvier 1573.
81. CCXCVIIe
DÉPESCHE
—du XXV
e
jour de janvier 1573.—
(Envoyée jusques à Calais par un marchand de Londres.)
Résolution des protestans de hâter l'expédition de leurs secours pour la
Rochelle.
Au Roy.
Sire, suyvant ce que je vous ay mandé, du XXII
e
du présent, que la
résolution avoit esté prinse icy entre quelques particulliers de
secourir la Rochelle, j'ay à vous dire maintenant qu'ilz préparent à
furie d'en exécuter promptement l'entreprise sans la vouloir différer,
ny à la fin de febvrier, ny au commancement de mars, comme ilz
l'avoient une foys pensé, parce qu'ilz se persuadent qu'estant desjà
Monsieur devant la place, il se pourroit bien fère, ayant avec luy
Monseigneur le Duc, et aultres princes, et bon nombre de grandz
cappitaines, et une brave armée, qu'il la forçât par sa dilligence et
valeur beaucoup plus tost qu'ilz ne peussent y avoyr pourveu. Dont
tout ce qui estoit de pirates, au long de la coste plus procheyne
d'icy, a faict desjà voylle vers le cap de Cornaille, et les françoys, qui
estoient en ceste ville, s'y retirent toutz pour s'y aller embarquer, car
c'est la poincte plus voysine de la Rochelle; sinon aulcuns des
principaulx qui ne bougent encores. Et je voy bien, Sire, par les
allées et venues que font aulcuns cappitaines de mer angloys en
82. Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com