Friday, January 28, 2011

Word Problem 1 - Stuffed Animals in Visual Basic

Morgan loves collecting small stuffed animals. She has 6 cows and 7 sheep. How many animals does she have in her collection?
Write a program in Visual Basic to display the number of stuffed animals in a message box.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim C, S, TA As Integer
'Set values
C = 6
S = 7
TA = C + S
'Display results
MessageBox.Show("Morgan has " & TA & " stuffed animals.")
End Sub
End Class

No comments:

Post a Comment