*/
Check out and contribute to CodePedia, the wiki for developers.
*/

View Standard Deviation\Form1.frm

Standard Deviation 1.0

Submitted By: graceson
Rating: starstarstarhalf star (Rate It)


VERSION 5.00
Begin VB.Form frmMain
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   5175
   ClientLeft      =   5385
   ClientTop       =   3315
   ClientWidth     =   4710
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5175
   ScaleWidth      =   4710
   Begin VB.CommandButton CmdExit
      Caption         =   "Exit"
      Height          =   375
      Left            =   120
      TabIndex        =   11
      Top             =   4680
      Width           =   1095
   End
   Begin VB.Timer TmrTime
      Interval        =   1000
      Left            =   4320
      Top             =   0
   End
   Begin VB.CommandButton CmdStandardDeviation
      Caption         =   "Standard Deviation"
      Height          =   375
      Left            =   3000
      TabIndex        =   7
      Top             =   4680
      Width           =   1575
   End
   Begin VB.Frame Frame2
      Caption         =   "Contents"
      Height          =   2775
      Left            =   120
      TabIndex        =   5
      Top             =   1800
      Width           =   4455
      Begin VB.CommandButton CmdSort
         Caption         =   "Sort"
         Height          =   375
         Left            =   1680
         TabIndex        =   12
         Top             =   2280
         Width           =   1095
      End
      Begin VB.CommandButton CmdClearAll
         Caption         =   "Clear"
         Height          =   375
         Left            =   120
         TabIndex        =   10
         Top             =   2280
         Width           =   975
      End
      Begin VB.CommandButton CmdDelete
         Caption         =   "Delete"
         Height          =   375
         Left            =   3360
         TabIndex        =   8
         Top             =   2280
         Width           =   975
      End
      Begin VB.ListBox LstStorage
         Height          =   1815
         ItemData        =   "Form1.frx":0000
         Left            =   120
         List            =   "Form1.frx":0002
         TabIndex        =   6
         Top             =   360
         Width           =   4215
      End
   End
   Begin VB.Frame Frame1
      Caption         =   "Add"
      Height          =   1215
      Left            =   120
      TabIndex        =   0
      Top             =   480
      Width           =   4455
      Begin VB.CommandButton CmdClear
         Caption         =   "Clear"
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   720
         Width           =   975
      End
      Begin VB.CommandButton CmdAdd
         Caption         =   "Add"
         Height          =   375
         Left            =   3360
         TabIndex        =   2
         Top             =   720
         Width           =   975
      End
      Begin VB.TextBox TxtInput
         Alignment       =   1  'Right Justify
         BeginProperty DataFormat
            Type            =   1
            Format          =   "0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   1
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   1
         ToolTipText     =   "Enter number here"
         Top             =   240
         Width           =   4215
      End
   End
   Begin VB.Label LblTime
      Caption         =   "Time"
      Height          =   375
      Left            =   2640
      TabIndex        =   9
      Top             =   120
      Width           =   1935
   End
   Begin VB.Label LblToday
      Caption         =   "Today :"
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   120
      Width           =   2415
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Option Explicit

'********************
'* Global Variables *
'********************
Dim arrStorage() As Double

'**************************
'* User defined functions *
'**************************

'Clear the textbox
Private Sub Clear()
    TxtInput.Text = ""
End Sub

'Sort Listbox(LstStorage) in ascending order
Private Sub SortList()
    Dim i, j As Byte
    Dim temp As Integer
    CopyToArray
    For i = 0 To LstStorage.ListCount - 1 Step 1
        For j = 0 To LstStorage.ListCount - 1 Step 1
            If arrStorage(i) < arrStorage(j) Then
                temp = arrStorage(i)
                arrStorage(i) = arrStorage(j)
                arrStorage(j) = temp
            End If
        Next
    Next
    CopyToListbox
End Sub

'Copy to Array (ArrStorage)
Private Sub CopyToArray()
    Dim i As Integer
    ReDim arrStorage(LstStorage.ListCount)
    For i = 0 To LstStorage.ListCount - 1 Step 1
        arrStorage(i) = LstStorage.List(i)
    Next
End Sub
'Copy to Listbox (LstStorage)
Private Sub CopyToListbox()
    Dim i As Integer
    For i = 0 To LstStorage.ListCount - 1 Step 1
         LstStorage.List(i) = arrStorage(i)
    Next
End Sub

'Add the value stored in the listbox(lstStorage)
'arrange it in a way that the last entry will be on the first slot

Private Sub AddToStorage(ByVal Num As Double)
    Dim i
    If LstStorage.ListCount = 0 Then
        LstStorage.AddItem Num
    Else
        LstStorage.AddItem 0
        For i = LstStorage.ListCount - 1 To 0 Step -1
            LstStorage.List(i) = Val(LstStorage.List(i - 1))
        Next
        LstStorage.List(0) = Num
    End If
End Sub
'*******************************
'*-----------------------------*
'*******************************

Private Sub CmdAdd_Click()
    AddToStorage (Val(TxtInput.Text))
    TxtInput.Text = ""
End Sub

Private Sub CmdClear_Click()
    Clear
End Sub

Private Sub CmdClearAll_Click()
    LstStorage.Clear
    Clear
End Sub

Private Sub CmdDelete_Click()
    Dim i As Integer
    For i = LstStorage.ListCount - 1 To 0 Step -1
        If LstStorage.Selected(i) Then
            LstStorage.RemoveItem (i)
            i = i - i
        End If
    Next
End Sub

Private Sub CmdExit_Click()
    Load frmExitPage
    frmExitPage.Show
    Unload Me
End Sub

Private Sub CmdSort_Click()
    SortList
End Sub

Private Sub CmdStandardDeviation_Click()
    SortList
    Load frmStandardDeviation
    frmStandardDeviation.Refresh
    frmStandardDeviation.Show
    frmMain.Hide
End Sub

Private Sub Form_Load()
    LblToday.Caption = "Today :  " & Format(Date, "MM - DD- YYYY")
    LblTime.Caption = "Time :   " & Time
End Sub

Private Sub TmrTime_Timer()
    LblTime.Caption = "Time :   " & Time
End Sub

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.