input from user from .txt

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2007
Posts: 13
Reputation: ashblynn02 is an unknown quantity at this point 
Solved Threads: 0
ashblynn02 ashblynn02 is offline Offline
Newbie Poster

input from user from .txt

 
0
  #1
Nov 8th, 2007
First off, Thanks again for all your guys help

I worked on a project where the user was supposed to enter numbers one at a time. After each number is entered, the program is to display the number of inputs, the total numbers entered, the average, the maximum and the minimum.

But what I am trying to accomplish now (just to further myself in this field) is: Instead of the user entering numbers one at a time as in my orginal program, I want the program to read the input numbers from a text file. When the first number is requested, that data file is to be opened and the first number read and processed. The file is then to be left open for the rest of the numbers to be read. When the program is at its end, the file will be closed. A restart button is to allow the orginal file or another file to be read from the beginning.

----Orginal Project----

[Public Class Form1
Dim InpNumber, InpTotal, InpCount, InpAverage As Double
Dim InpMaximum, InpMinimum As Double

Private Sub BtnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEnter.Click
InpNumber = CDbl(txtInput.Text)

If InpCount = 0 Then
InpTotal = InpNumber
InpAverage = InpNumber
InpMinimum = InpNumber
InpMaximum = InpNumber
InpCount = InpCount + 1

Else
InpCount = InpCount + 1
InpTotal = InpTotal + InpNumber
InpAverage = InpTotal / InpCount
End If

If InpMinimum > InpNumber Then
InpMinimum = InpNumber
End If

If InpMaximum < InpNumber Then
InpMaximum = InpNumber
End If


txttotal.Text = CStr(InpTotal)
txtaverage.Text = CStr(InpAverage)
txtmin.Text = CStr(InpMinimum)
txtmax.Text = CStr(InpMaximum)
txtcount.Text = CStr(InpCount)
End Sub

Private Sub BtnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReset.Click
InpNumber = CDbl(txtInput.Text)

If InpNumber = InpNumber Then
InpTotal = 0
InpAverage = 0
InpMinimum = 0
InpMaximum = 0
InpCount = 0
InpNumber = 0
End If


txtInput.Text = CStr(InpNumber)
txttotal.Text = CStr(InpTotal)
txtaverage.Text = CStr(InpAverage)
txtmin.Text = CStr(InpMinimum)
txtmax.Text = CStr(InpMaximum)
txtcount.Text = CStr(InpCount)

End Sub

End Class]
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 538
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: input from user from .txt

 
0
  #2
Nov 9th, 2007
u have posted the thread in the wrong forum. post it in the vb.net forum after that ur question will be answered.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 599 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC