Solved

Compare numbers in a file

Posted on 2004-10-10
8
153 Views
Last Modified: 2010-04-23
I need some assistance in writing part of a program. What I need is a means to update / append a local XML file with numbers that a user inputs from a form and then find the most common and least common numbers in the file and show them on the form.  

On the form, users input (the numbers) in seperate text boxes one number for each textbox (there should be 7 of them) One button is needed to do the update / append and another button to clear the information from the file (like a clear all) if the user wants to clear the contents of the file and start all over and a third button to tell the program to do the calculations needed.  

The input numbers could range from 0 to 99 only and should be restricted with validation when the user inputs the numbers on the forms text boxes so only numbers 0 to 99 are valid entries.  

I was thinking file would need to be something with the look and feel of an INI file but  in XML format key/value pairs but the format and type of file is negotiable if there are better suggestions to store the input aside from a database.  My users do not have any other programs installed to be able to use a real database of any type plus I think it would be overkill for this project.

A lot of description but in a nut shell; I need to update a file with numbers, the program takes the numbers and displays the most frequently and least frequently occuring numbers and shows them to the user.  Anyone have good code that will do this or is it something a little more difficult than I can get help with here?  I have been considering putting this on Rentacoder.com to have someone write for me but I didn't know how difficult it would be.

Thanks for any suggestions or code help with this.
0
Comment
Question by:teamdad
  • 5
  • 3
8 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 12273636
Try this application out:

Imports System.IO

Public Class Form1
    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

    '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 NumericUpDown1 As System.Windows.Forms.NumericUpDown
    Friend WithEvents NumericUpDown2 As System.Windows.Forms.NumericUpDown
    Friend WithEvents NumericUpDown3 As System.Windows.Forms.NumericUpDown
    Friend WithEvents NumericUpDown4 As System.Windows.Forms.NumericUpDown
    Friend WithEvents NumericUpDown5 As System.Windows.Forms.NumericUpDown
    Friend WithEvents NumericUpDown6 As System.Windows.Forms.NumericUpDown
    Friend WithEvents NumericUpDown7 As System.Windows.Forms.NumericUpDown
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
        Me.NumericUpDown2 = New System.Windows.Forms.NumericUpDown
        Me.NumericUpDown3 = New System.Windows.Forms.NumericUpDown
        Me.NumericUpDown4 = New System.Windows.Forms.NumericUpDown
        Me.NumericUpDown5 = New System.Windows.Forms.NumericUpDown
        Me.NumericUpDown6 = New System.Windows.Forms.NumericUpDown
        Me.NumericUpDown7 = New System.Windows.Forms.NumericUpDown
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.ListBox2 = New System.Windows.Forms.ListBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.NumericUpDown3, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.NumericUpDown4, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.NumericUpDown5, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.NumericUpDown6, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.NumericUpDown7, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'NumericUpDown1
        '
        Me.NumericUpDown1.Location = New System.Drawing.Point(16, 24)
        Me.NumericUpDown1.Maximum = New Decimal(New Integer() {99, 0, 0, 0})
        Me.NumericUpDown1.Name = "NumericUpDown1"
        Me.NumericUpDown1.Size = New System.Drawing.Size(40, 20)
        Me.NumericUpDown1.TabIndex = 0
        '
        'NumericUpDown2
        '
        Me.NumericUpDown2.Location = New System.Drawing.Point(64, 24)
        Me.NumericUpDown2.Maximum = New Decimal(New Integer() {99, 0, 0, 0})
        Me.NumericUpDown2.Name = "NumericUpDown2"
        Me.NumericUpDown2.Size = New System.Drawing.Size(40, 20)
        Me.NumericUpDown2.TabIndex = 1
        '
        'NumericUpDown3
        '
        Me.NumericUpDown3.Location = New System.Drawing.Point(112, 24)
        Me.NumericUpDown3.Maximum = New Decimal(New Integer() {99, 0, 0, 0})
        Me.NumericUpDown3.Name = "NumericUpDown3"
        Me.NumericUpDown3.Size = New System.Drawing.Size(40, 20)
        Me.NumericUpDown3.TabIndex = 2
        '
        'NumericUpDown4
        '
        Me.NumericUpDown4.Location = New System.Drawing.Point(160, 24)
        Me.NumericUpDown4.Maximum = New Decimal(New Integer() {99, 0, 0, 0})
        Me.NumericUpDown4.Name = "NumericUpDown4"
        Me.NumericUpDown4.Size = New System.Drawing.Size(40, 20)
        Me.NumericUpDown4.TabIndex = 3
        '
        'NumericUpDown5
        '
        Me.NumericUpDown5.Location = New System.Drawing.Point(208, 24)
        Me.NumericUpDown5.Maximum = New Decimal(New Integer() {99, 0, 0, 0})
        Me.NumericUpDown5.Name = "NumericUpDown5"
        Me.NumericUpDown5.Size = New System.Drawing.Size(40, 20)
        Me.NumericUpDown5.TabIndex = 4
        '
        'NumericUpDown6
        '
        Me.NumericUpDown6.Location = New System.Drawing.Point(256, 24)
        Me.NumericUpDown6.Maximum = New Decimal(New Integer() {99, 0, 0, 0})
        Me.NumericUpDown6.Name = "NumericUpDown6"
        Me.NumericUpDown6.Size = New System.Drawing.Size(40, 20)
        Me.NumericUpDown6.TabIndex = 5
        '
        'NumericUpDown7
        '
        Me.NumericUpDown7.Location = New System.Drawing.Point(304, 24)
        Me.NumericUpDown7.Maximum = New Decimal(New Integer() {99, 0, 0, 0})
        Me.NumericUpDown7.Name = "NumericUpDown7"
        Me.NumericUpDown7.Size = New System.Drawing.Size(40, 20)
        Me.NumericUpDown7.TabIndex = 6
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(256, 56)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(80, 24)
        Me.Button1.TabIndex = 7
        Me.Button1.Text = "Append File"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(160, 56)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(80, 24)
        Me.Button2.TabIndex = 8
        Me.Button2.TabStop = False
        Me.Button2.Text = "Clear File"
        '
        'ListBox1
        '
        Me.ListBox1.Location = New System.Drawing.Point(32, 64)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(136, 160)
        Me.ListBox1.TabIndex = 9
        Me.ListBox1.TabStop = False
        '
        'ListBox2
        '
        Me.ListBox2.Location = New System.Drawing.Point(184, 64)
        Me.ListBox2.Name = "ListBox2"
        Me.ListBox2.Size = New System.Drawing.Size(136, 160)
        Me.ListBox2.TabIndex = 10
        Me.ListBox2.TabStop = False
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(128, 16)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "Label1"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(184, 24)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(136, 16)
        Me.Label2.TabIndex = 12
        Me.Label2.Text = "Label2"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(24, 48)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(136, 16)
        Me.Label3.TabIndex = 13
        Me.Label3.Text = "Least Frequent Values:"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(184, 48)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(136, 16)
        Me.Label4.TabIndex = 14
        Me.Label4.Text = "Most Frequent Values:"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Button2)
        Me.GroupBox1.Controls.Add(Me.Button1)
        Me.GroupBox1.Controls.Add(Me.NumericUpDown7)
        Me.GroupBox1.Controls.Add(Me.NumericUpDown6)
        Me.GroupBox1.Controls.Add(Me.NumericUpDown5)
        Me.GroupBox1.Controls.Add(Me.NumericUpDown4)
        Me.GroupBox1.Controls.Add(Me.NumericUpDown3)
        Me.GroupBox1.Controls.Add(Me.NumericUpDown2)
        Me.GroupBox1.Controls.Add(Me.NumericUpDown1)
        Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(360, 96)
        Me.GroupBox1.TabIndex = 15
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = " Data Entry "
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.ListBox2)
        Me.GroupBox2.Controls.Add(Me.Label3)
        Me.GroupBox2.Controls.Add(Me.Label2)
        Me.GroupBox2.Controls.Add(Me.Label1)
        Me.GroupBox2.Controls.Add(Me.ListBox1)
        Me.GroupBox2.Controls.Add(Me.Label4)
        Me.GroupBox2.Location = New System.Drawing.Point(8, 112)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(360, 240)
        Me.GroupBox2.TabIndex = 16
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = " Analysis "
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(376, 358)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Name = "Form1"
        Me.Text = "Number Frequency Analyzer"
        CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.NumericUpDown3, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.NumericUpDown4, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.NumericUpDown5, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.NumericUpDown6, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.NumericUpDown7, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim fileName As String = Application.StartupPath & "\Numbers.txt"
    Dim frequencies As Hashtable
    Dim leastOccurring As SortedList
    Dim mostOccurring As SortedList
    Dim minOccurrence As Integer
    Dim maxOccurrence As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        analyzeNumbers()
    End Sub

    Private Sub NumericUpDown_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) _
            Handles NumericUpDown1.GotFocus, NumericUpDown2.GotFocus, NumericUpDown3.GotFocus, _
            NumericUpDown4.GotFocus, NumericUpDown5.GotFocus, NumericUpDown6.GotFocus, NumericUpDown7.GotFocus
        Dim nud As NumericUpDown = CType(sender, NumericUpDown)
        nud.Select(0, nud.Text.Length)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sw As New StreamWriter(fileName, True)
        Dim output As String
        output = NumericUpDown1.Value.ToString & ";" & _
            NumericUpDown2.Value.ToString & ";" & _
            NumericUpDown3.Value.ToString & ";" & _
            NumericUpDown4.Value.ToString & ";" & _
            NumericUpDown5.Value.ToString & ";" & _
            NumericUpDown6.Value.ToString & ";" & _
            NumericUpDown7.Value.ToString
        sw.WriteLine(output)
        sw.Close()
        analyzeNumbers()
        NumericUpDown1.Focus()
    End Sub

    Private Sub analyzeNumbers()
        Label1.Text = ""
        Label2.Text = ""
        ListBox1.Items.Clear()
        ListBox2.Items.Clear()

        If Not File.Exists(fileName) Then
            Exit Sub
        End If

        ' Analyze File
        frequencies = New Hashtable
        Dim sr As New StreamReader(fileName)
        Dim inputLine As String
        Dim values As String()
        Dim value As String
        Dim intValue As Integer
        Dim valueFrequency As Integer
        inputLine = sr.ReadLine
        While Not (inputLine Is Nothing)
            values = Split(inputLine, ";")
            For Each value In values
                Try
                    valueFrequency = 0
                    intValue = Integer.Parse(value)
                    If frequencies.ContainsKey(intValue) Then
                        valueFrequency = CType(frequencies.Item(intValue), Integer)
                    End If
                    valueFrequency = valueFrequency + 1
                    frequencies.Item(intValue) = valueFrequency
                Catch ex As Exception
                    MessageBox.Show(inputLine, "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End Try
            Next
            inputLine = sr.ReadLine
        End While
        sr.Close()

        ' Find min and max occurrence
        Dim de As DictionaryEntry
        minOccurrence = 0
        maxOccurrence = 0
        For Each de In frequencies
            intValue = CType(de.Key, Integer)
            valueFrequency = CType(de.Value, Integer)
            If minOccurrence = 0 Then
                minOccurrence = valueFrequency
                maxOccurrence = valueFrequency
            Else
                minOccurrence = Math.Min(minOccurrence, valueFrequency)
                maxOccurrence = Math.Max(maxOccurrence, valueFrequency)
            End If
        Next

        ' Build lists of values matching min and max occurrence
        leastOccurring = New SortedList
        mostOccurring = New SortedList
        For Each de In frequencies
            intValue = CType(de.Key, Integer)
            valueFrequency = CType(de.Value, Integer)
            If valueFrequency = minOccurrence Then
                leastOccurring.Add(intValue, intValue)
            End If
            If valueFrequency = maxOccurrence Then
                mostOccurring.Add(intValue, intValue)
            End If
        Next

        ' Display the results
        Label1.Text = "Min Frequency: " & minOccurrence
        Label2.Text = "Max Frequency: " & maxOccurrence
        For Each intValue In leastOccurring.Values
            ListBox1.Items.Add(intValue)
        Next
        For Each intValue In mostOccurring.Values
            ListBox2.Items.Add(intValue)
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If File.Exists(fileName) Then
            File.Delete(fileName)
            analyzeNumbers()
        End If
    End Sub
End Class
0
 

Author Comment

by:teamdad
ID: 12278527
Excellant piece of work Idle_Mind I love it.  Would there be a way to have the numbers show in a format like 1, 2, 3, 4 etc... instead of being in a list like they are now with the list boxes? And I have discovered a flaw in my thoughts after seeing a working piece of software; after the button is pressed to append the numbers to the text file I need a way to prevent the same numbers from being appended if the person just sits there and clicks the button over and over, I only need one set of entered numbers to be appended and no repeats of the same set over and over.  

I was thinking maybe something like after the button is pressed it resets the numeric up down's to null and then validate it to not accept all values of null so it would prevent repeat button presses and would force the user to put in new numbers each time to append.  Could these things be done with little adjustment?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12278780
You can build your list of occurring values in a fashion similar to this:

        ' Display the results
        Label1.Text = "Min Frequency: " & minOccurrence
        Label2.Text = "Max Frequency: " & maxOccurrence
        Dim OccurringValues As String
        For Each intValue In leastOccurring.Values
            If OccurringValues = "" Then
                OccurringValues = intValue.ToString
            Else
                OccurringValues = OccurringValues & ", " & intValue.ToString
            End If
        Next
        Label3.Text = "Least Frequent Values:" & vbCrLf & OccurringValues

        OccurringValues = ""
        For Each intValue In mostOccurring.Values
            If OccurringValues = "" Then
                OccurringValues = intValue.ToString
            Else
                OccurringValues = OccurringValues & ", " & intValue.ToString
            End If
        Next
        Label4.Text = "Most Frequent Values:" & vbCrLf & OccurringValues

Let me think of a good way to prevent the "Append File" button from being continously pushed.  The NumericUpDown control will not let you set its value to null.

~IM
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12279136
Change the minimum value for all the NumericUpDownControls to -1 and set their initial value to -1.  Set the initial enabled state of Button1 to false.  Then you can use the following code to reenable the button when valid values have been entered:

    Private Sub NumericUpDown_TextChanged(ByVal sender As Object, ByVal e As EventArgs) _
            Handles NumericUpDown1.TextChanged, NumericUpDown2.TextChanged, NumericUpDown3.TextChanged, _
            NumericUpDown4.TextChanged, NumericUpDown5.TextChanged, NumericUpDown6.TextChanged, NumericUpDown7.TextChanged
        Button1.Enabled = True
        Dim c As Control
        Dim nud As NumericUpDown
        For Each c In GroupBox1.Controls
            If TypeOf c Is NumericUpDown Then
                nud = CType(c, NumericUpDown)
                If nud.Value = -1 Then
                    Button1.Enabled = False
                    Exit Sub
                End If
            End If
        Next
    End Sub

Change the Button1_Click code to this:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sw As New StreamWriter(fileName, True)
        Dim output As String
        output = NumericUpDown1.Value.ToString & ";" & _
            NumericUpDown2.Value.ToString & ";" & _
            NumericUpDown3.Value.ToString & ";" & _
            NumericUpDown4.Value.ToString & ";" & _
            NumericUpDown5.Value.ToString & ";" & _
            NumericUpDown6.Value.ToString & ";" & _
            NumericUpDown7.Value.ToString
        sw.WriteLine(output)
        sw.Close()
        analyzeNumbers()

        Dim c As Control
        Dim nud As NumericUpDown
        For Each c In GroupBox1.Controls
            If TypeOf c Is NumericUpDown Then
                nud = CType(c, NumericUpDown)
                nud.Value = -1
            End If
        Next
        NumericUpDown1.Focus()
    End Sub

~IM
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:teamdad
ID: 12283252
I like the code for both suggestions and have started using the code to build the list of values but the changes to  keep the user from continously pushing the "Append" button keeps the -1 value in the Numeric up down's instead of starting them at 0.  I have thout up this bit of code below to get around it.  It  has the user verify if they want to append all zeros to the file before it will accept all zeros to be saved.  I also rethought changing the Button2 "Clear All" to just delete the last entry in the file that has been appended.  It's too easy for someone to push a button and delete thousands of records like that in one swipe, this way they would only be taking out the last entry just in case they made a mistake with their entry.  Being still new at VB.NET I haven't got either of them to work yet.

Here's what I have so far on the verification but I haven't got the missing parts to get it working.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If NumericUpDown1.Value = "0" And NumericUpDown2.Value = "0" And NumericUpDown3.Value = "0" And NumericUpDown4.Value = "0" And NumericUpDown5.Value = "0" And NumericUpDown6.Value = "0" And NumericUpDown7.Value = "0" Then
            MessageBox.Show("Do you want to save all zeros?", "Please verify for me", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If (DialogResult.Yes) Then
               ' Do the next step in calculating the numbers
            ElseIf (DialogResult.No) Then
                ' Don't do anything and put focus back on NumericUpDown1
            End If
        End If

0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12283403
Here are some different implementations for your button clicks:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If NumericUpDown1.Value = 0 AndAlso NumericUpDown2.Value = 0 AndAlso _
            NumericUpDown3.Value = 0 AndAlso NumericUpDown4.Value = 0 AndAlso _
            NumericUpDown5.Value = 0 AndAlso NumericUpDown6.Value = 0 AndAlso _
            NumericUpDown7.Value = 0 Then

            If MessageBox.Show("Do you want to save all zeros?", "Please verify for me", MessageBoxButtons.YesNo, MessageBoxIcon.Question) <> DialogResult.Yes Then
                NumericUpDown1.Focus()
                Exit Sub
            End If
        End If

        Dim sw As New StreamWriter(fileName, True)
        Dim output As String
        output = NumericUpDown1.Value.ToString & ";" & _
            NumericUpDown2.Value.ToString & ";" & _
            NumericUpDown3.Value.ToString & ";" & _
            NumericUpDown4.Value.ToString & ";" & _
            NumericUpDown5.Value.ToString & ";" & _
            NumericUpDown6.Value.ToString & ";" & _
            NumericUpDown7.Value.ToString
        sw.WriteLine(output)
        sw.Close()

        analyzeNumbers()

        NumericUpDown1.Value = 0
        NumericUpDown2.Value = 0
        NumericUpDown3.Value = 0
        NumericUpDown4.Value = 0
        NumericUpDown5.Value = 0
        NumericUpDown6.Value = 0
        NumericUpDown7.Value = 0

        NumericUpDown1.Focus()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim msg As String = "All data will be permanently lost." & vbCrLf & _
            "Are you sure you want to delete the data file?"
        If MessageBox.Show(msg, "Deleting Data File", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then
            If File.Exists(fileName) Then
                File.Delete(fileName)
                MsgBox("File Deleted", MsgBoxStyle.Information, "Delete Data File")
                analyzeNumbers()
            End If
        End If
    End Sub
0
 

Author Comment

by:teamdad
ID: 12283701
Idle_Mind, it's been a pleasure working with you on this..... sorry I asked so many questions and I know you didn't have to go through all that code for me but I do thank you a lot for the great help you have given me.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12283738
My pleasure!  ...and you didn't ask to many questions.  =)

~IM
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now