Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi,

 

how is possbile to draw a chart with the last 6 months (if you open the application in december, will draw chart from July to december) and the info from a text file like :

 

50

60

20

40

30

 

thanks

Posted

I made the chart, with 6 parameters, but now I want just to take the numbers from the text file and to put them into some variables... but how ??

 

ex:

 

50 > var1

60 > var2

20 > var3

40 > var4

30 > var5

36 > var6

Posted
Sorry if I'm slow minded but ... I didn't get the idea ... What are those numbers for ? Why are they stored in a text file?
Software bugs are impossible to detect by anybody except the end user.
Posted

the file with data (60 50 80 70 90 etc...) will be generated by an equipment for monitoring some stuff.

 

I want to take this file to make a chart with this values. Every day will be a different value ..so the chart must be updated from this file every day.

 

All I want to know is how I can take this values fron the text file to put in variables. I can take only if is a sigle value in the file and put in a single variable. Don't know how to make several variables from this file when I have more than one number.

 

thanks

Posted (edited)

Ok ... it goes like this :

 

 

 

       Const FilePath As String = "c:\test.txt"

       Dim sr As New System.IO.StreamReader(FilePath)
       Dim lines As Integer
       Dim Vals As New ArrayList      'Array of integers

       'Counts the lines on the file
       Dim str As String
       Do
           str = sr.ReadLine()
           lines += 1
       Loop While (Not str = "")
       lines -= 1
       sr.Close()

       'Reopen the file from the begining
       sr = New System.IO.StreamReader(FilePath)

       'Set the position on the 6th value from the end
       For jump As Integer = 1 To lines - 6
           sr.ReadLine()
       Next

       'Read the last 6 values into an array of integers
       'If you wish change it to Double...
       For i As Integer = 0 To 5
           Vals.Add(Val(sr.ReadLine))
       Next

 

 

In the end you have an Array named Vals with 6 item on it from 0 to 5 witch are the six last values on your file !

 

Is it ok for you :D

 

Anything else ... just ask !

Edited by AlexCode
Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...