Option Explicit On 
Option Strict On

Public Class frmPennies
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents lblSum As System.Windows.Forms.Label
  Friend WithEvents btnSum As System.Windows.Forms.Button

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label()
    Me.lblSum = New System.Windows.Forms.Label()
    Me.btnSum = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.Location = New System.Drawing.Point(16, 16)
    Me.Label1.Name = "Label1"
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Sum"
    '
    'lblSum
    '
    Me.lblSum.BackColor = System.Drawing.Color.White
    Me.lblSum.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.lblSum.Location = New System.Drawing.Point(112, 8)
    Me.lblSum.Name = "lblSum"
    Me.lblSum.Size = New System.Drawing.Size(120, 23)
    Me.lblSum.TabIndex = 1
    Me.lblSum.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
    '
    'btnSum
    '
    Me.btnSum.Location = New System.Drawing.Point(72, 48)
    Me.btnSum.Name = "btnSum"
    Me.btnSum.Size = New System.Drawing.Size(112, 23)
    Me.btnSum.TabIndex = 2
    Me.btnSum.Text = "&Sum Pennies"
    '
    'frmPennies
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(260, 105)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnSum, Me.lblSum, Me.Label1})
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
    Me.Name = "frmPennies"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Pennies Problem"
    Me.ResumeLayout(False)

  End Sub

#End Region

  
  Private Sub btnSum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSum.Click
    Dim NumberPennies As Integer
    Dim Sum As Integer
    Dim Days As Integer
    'After one day, you have one penny
    NumberPennies = 1
    Sum = 1
    For Days = 2 To 30
      'double pennies each day
      NumberPennies *= 2
      Sum += NumberPennies
    Next
    'Display dollar amount
    lblSum.Text = Format(Sum / 100, "$0,000.00")
  End Sub
End Class
