Hey guy's I would like so much if one of you could look at the logic in the Private Sub AveragePrice(), I cant seem to get it to average the gdblPrices array correctly. Any help would be appreciated.
CODE
#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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'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.
Friend WithEvents txtAverage As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents txtAskingPrice As System.Windows.Forms.TextBox
Friend WithEvents txtZip As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents txtAddress As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtCity As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents stbRecords As System.Windows.Forms.StatusBar
Friend WithEvents stpRecords As System.Windows.Forms.StatusBarPanel
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents mnuExit As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents mnuNext As System.Windows.Forms.MenuItem
Friend WithEvents mnuPrevious As System.Windows.Forms.MenuItem
Friend WithEvents mnuFirst As System.Windows.Forms.MenuItem
Friend WithEvents mnuLast As System.Windows.Forms.MenuItem
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents cmuFirst As System.Windows.Forms.MenuItem
Friend WithEvents cmuLast As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
Friend WithEvents cmuPrevious As System.Windows.Forms.MenuItem
Friend WithEvents cmuNext As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.txtAverage = New System.Windows.Forms.TextBox
Me.Label5 = New System.Windows.Forms.Label
Me.txtAskingPrice = New System.Windows.Forms.TextBox
Me.txtZip = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.txtAddress = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.txtCity = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.stbRecords = New System.Windows.Forms.StatusBar
Me.stpRecords = New System.Windows.Forms.StatusBarPanel
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.mnuExit = New System.Windows.Forms.MenuItem
Me.MenuItem3 = New System.Windows.Forms.MenuItem
Me.mnuNext = New System.Windows.Forms.MenuItem
Me.mnuPrevious = New System.Windows.Forms.MenuItem
Me.mnuFirst = New System.Windows.Forms.MenuItem
Me.mnuLast = New System.Windows.Forms.MenuItem
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
Me.cmuFirst = New System.Windows.Forms.MenuItem
Me.cmuLast = New System.Windows.Forms.MenuItem
Me.MenuItem5 = New System.Windows.Forms.MenuItem
Me.cmuPrevious = New System.Windows.Forms.MenuItem
Me.cmuNext = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
CType(Me.stpRecords, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'txtAverage
'
Me.txtAverage.Location = New System.Drawing.Point(128, 144)
Me.txtAverage.Name = "txtAverage"
Me.txtAverage.ReadOnly = True
Me.txtAverage.Size = New System.Drawing.Size(80, 20)
Me.txtAverage.TabIndex = 23
Me.txtAverage.Text = ""
Me.txtAverage.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(16, 144)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(104, 24)
Me.Label5.TabIndex = 24
Me.Label5.Text = "Average price of all homes listed:"
'
'txtAskingPrice
'
Me.txtAskingPrice.Location = New System.Drawing.Point(104, 80)
Me.txtAskingPrice.Name = "txtAskingPrice"
Me.txtAskingPrice.ReadOnly = True
Me.txtAskingPrice.Size = New System.Drawing.Size(80, 20)
Me.txtAskingPrice.TabIndex = 15
Me.txtAskingPrice.Text = ""
Me.txtAskingPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'txtZip
'
Me.txtZip.Location = New System.Drawing.Point(192, 48)
Me.txtZip.Name = "txtZip"
Me.txtZip.ReadOnly = True
Me.txtZip.Size = New System.Drawing.Size(48, 20)
Me.txtZip.TabIndex = 22
Me.txtZip.Text = ""
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(160, 48)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(32, 16)
Me.Label4.TabIndex = 21
Me.Label4.Text = "Zip:"
'
'txtAddress
'
Me.txtAddress.Location = New System.Drawing.Point(72, 16)
Me.txtAddress.Name = "txtAddress"
Me.txtAddress.ReadOnly = True
Me.txtAddress.Size = New System.Drawing.Size(168, 20)
Me.txtAddress.TabIndex = 20
Me.txtAddress.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(104, 16)
Me.Label1.TabIndex = 19
Me.Label1.Text = "Address:"
'
'txtCity
'
Me.txtCity.Location = New System.Drawing.Point(72, 48)
Me.txtCity.Name = "txtCity"
Me.txtCity.ReadOnly = True
Me.txtCity.Size = New System.Drawing.Size(72, 20)
Me.txtCity.TabIndex = 18
Me.txtCity.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(104, 16)
Me.Label3.TabIndex = 17
Me.Label3.Text = "Asking price:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(32, 16)
Me.Label2.TabIndex = 16
Me.Label2.Text = "City:"
'
'stbRecords
'
Me.stbRecords.Location = New System.Drawing.Point(0, 187)
Me.stbRecords.Name = "stbRecords"
Me.stbRecords.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.stpRecords})
Me.stbRecords.ShowPanels = True
Me.stbRecords.Size = New System.Drawing.Size(274, 24)
Me.stbRecords.SizingGrip = False
Me.stbRecords.TabIndex = 25
Me.stbRecords.Text = "StatusBar1"
'
'stpRecords
'
Me.stpRecords.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.stpRecords.Text = "Record 1 of 5"
Me.stpRecords.Width = 274
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem3})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuExit})
Me.MenuItem1.Text = "&File"
'
'mnuExit
'
Me.mnuExit.Index = 0
Me.mnuExit.Text = "E&xit"
'
'MenuItem3
'
Me.MenuItem3.Index = 1
Me.MenuItem3.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNext, Me.mnuPrevious, Me.MenuItem2, Me.mnuFirst, Me.mnuLast})
Me.MenuItem3.Text = "&Record"
'
'mnuNext
'
Me.mnuNext.Index = 0
Me.mnuNext.Shortcut = System.Windows.Forms.Shortcut.CtrlN
Me.mnuNext.Text = "&Next"
'
'mnuPrevious
'
Me.mnuPrevious.Index = 1
Me.mnuPrevious.Shortcut = System.Windows.Forms.Shortcut.CtrlP
Me.mnuPrevious.Text = "&Previous"
'
'mnuFirst
'
Me.mnuFirst.Index = 3
Me.mnuFirst.Shortcut = System.Windows.Forms.Shortcut.CtrlF
Me.mnuFirst.Text = "&First"
'
'mnuLast
'
Me.mnuLast.Index = 4
Me.mnuLast.Shortcut = System.Windows.Forms.Shortcut.CtrlL
Me.mnuLast.Text = "&Last"
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.cmuFirst, Me.cmuLast, Me.MenuItem5, Me.cmuPrevious, Me.cmuNext})
'
'cmuFirst
'
Me.cmuFirst.Index = 0
Me.cmuFirst.Text = "First"
'
'cmuLast
'
Me.cmuLast.Index = 1
Me.cmuLast.Text = "Last"
'
'MenuItem5
'
Me.MenuItem5.Index = 2
Me.MenuItem5.Text = "-"
'
'cmuPrevious
'
Me.cmuPrevious.Index = 3
Me.cmuPrevious.Text = "Previous"
'
'cmuNext
'
Me.cmuNext.Index = 4
Me.cmuNext.Text = "Next"
'
'MenuItem2
'
Me.MenuItem2.Index = 2
Me.MenuItem2.Text = "-"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(274, 211)
Me.ContextMenu = Me.ContextMenu1
Me.Controls.Add(Me.stbRecords)
Me.Controls.Add(Me.txtAverage)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.txtAskingPrice)
Me.Controls.Add(Me.txtZip)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.txtAddress)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.txtCity)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Menu = Me.MainMenu1
Me.MinimizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Ganden Real Estate"
CType(Me.stpRecords, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim gdblPrices As Double() = {128743.0, 155899.0, 131999.0, 145500.0, 163200.0}
Dim gstrAddresses As String(,) = { _
{"3521 Twin Oaks", "Glendale", "60623"}, _
{"4320 Hessin", "Oakton", "60543"}, _
{"1534 Wilmington Ct.", "Woodglen", "32342"}, _
{"22123 103rd Street", "Lance", "30433"}, _
{"8743 East Harcourt", "Westdale", "39393"}}
Dim gintCurrentRecord As Integer
Private Sub AveragePrice()
Dim dblTotal As Double
Dim i As Double
For i = 0 To gdblPrices(4)
dblTotal += gdblPrices.Length - 1
Next
txtAverage.Text = Format(Convert.ToString(dblTotal / gdblPrices.Length - 1), "Currency")
End Sub
Private Sub DisplayRecord(ByVal intRecord As Integer)
If intRecord < 0 Then
intRecord = 0
End If
If intRecord > gdblPrices.Length - 1 Then
intRecord = gdblPrices.Length - 1
End If
gintCurrentRecord = intRecord
txtAddress.Text = gstrAddresses(intRecord, 0)
txtCity.Text = gstrAddresses(intRecord, 1)
txtZip.Text = gstrAddresses(intRecord, 2)
txtAskingPrice.Text = Format(gdblPrices(intRecord), "Currency")
stbRecords.Panels(0).Text = "Record " & intRecord + 1 & " of " & gdblPrices.GetUpperBound(0) + 1
AveragePrice()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisplayRecord(2)
End Sub
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
Me.Close()
End
End Sub
Private Sub mnuNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNext.Click
DisplayRecord(gintCurrentRecord + 1)
End Sub
Private Sub mnuPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrevious.Click
DisplayRecord(gintCurrentRecord - 1)
End Sub
Private Sub mnuFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFirst.Click
DisplayRecord(0)
End Sub
Private Sub mnuLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLast.Click
DisplayRecord(4)
End Sub
Private Sub cmuFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmuFirst.Click
mnuFirst.PerformClick()
End Sub
Private Sub cmuLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmuLast.Click
mnuLast.PerformClick()
End Sub
Private Sub cmuPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmuPrevious.Click
mnuPrevious.PerformClick()
End Sub
Private Sub cmuNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmuNext.Click
mnuNext.PerformClick()
End Sub
End Class