• Home
  • Textbooks
  • Microsoft Visual Basic Programs to Accompany Programming Logic and Design
  • Advanced Array Techniques

Microsoft Visual Basic Programs to Accompany Programming Logic and Design

Jo Ann Smith

Chapter 8

Advanced Array Techniques - all with Video Answers

Educators


Section 1

Swapping Values

Problem 1

Suppose you have declared and initialized two String variables, name1 and name2, in a Visual Basic program. Now, you want to swap the values stored in name1 and name2, but only if the value of name1 is greater than the value of name2.
Write the Visual Basic code that accomplishes this task. The declarations are as follows:
Dim name1 As String = "Smith"
Dim name2 As String = "Smythe"
$\qquad$
$\qquad$
$\qquad$
$\qquad$

Check back soon!