Ace Master Posted October 30, 2003 Posted October 30, 2003 I have this code and I want to load seven different files for extracting some values from those files. Right now I can load a file named after the current day. 30102003.doz I want in form load to call a function for loading all files from 24102203.doz to 30102003.doz (all the last seven days beginning with current day) So..all I want is to build a function after my code here and sending some parameters for different files loading. In the end, I need to have: ex: vals1(3) = 30 vals2(3) = 43 vals3(3) = 54 vals4(3) = 54 vals5(3) = 76 vals6(3) = 24 vals1(3) = 86 I tried some tricks with no good results : ( Public Sub zi_() Dim zile(6) As String Dim z As Date Dim zs As New TimeSpan For day As Integer = 0 To 6 z = Date.Now zs = zs.FromDays(day) z = z.Subtract(zs) zile(day) = Format(z, "dd") Next Dim month_1 As String Dim year_1 As String Dim ext As String = ".doz" Dim cale As String = "doze\" month_1 = Format(Now, "MM") year_1 = Format(Now, "yyyy") cale_finala = cale + zile(0) + month_1 + year_1 + ext Dim sr1 As New System.IO.StreamReader(cale_finala) Dim Line1 As Object Dim space1 As Object = " " Dim enter1 As Object Line1 = sr1.ReadToEnd sr1.Close() vals1 = Line1.Split(space1) End Sub thanks Quote
Ace Master Posted November 6, 2003 Author Posted November 6, 2003 a little help here? I�m fighting for a while with this code and can�t find a viable solution for my problem. I still have those charts for the last seven days and the last six months. All I made by know is to have this chart displayed but with this problem: I load for each value from the chart a single value from one text file. So, if current day is 20 I load: 20102003.doz 19102003.doz 18102003.doz 17102003.doz 16102003.doz 15102003.doz 14102003.doz In those case all looks perfect�but the problem occurs when the current day is, let�s say..6 Nov 2003. In this case I need to load this files: 06112003.doz 05112003.doz 04112003.doz 03112003.doz 02112003.doz 01112003.doz 31102003.doz You see the problem? After I made my day subtraction the app is trying to load this file: 31112003.doz. The code I write can�t know the month is over and need to subtract the month to load the �31102003.doz� Of course the problem will appear when I will display the month charts in January. So, please if anybody can help me with this, I will be grateful. Thanks Quote
Moderators Robby Posted November 6, 2003 Moderators Posted November 6, 2003 You place a DateDiff() in your loop, this will take into account the month change. Quote Visit...Bassic Software
Ace Master Posted November 7, 2003 Author Posted November 7, 2003 thanks Thank you, is working now. Anybody has an idea how to load several text files. I have those daily files and I want to extract a value from each file of one month to calculate a medium value for a chart. Ex: If I want to see the medium value for October, I need to load all 31 files and to extract a specific value from each file (10,50,20,50,etc) and after that to add them and calculate the medium value like (10+50+20+50+..+n)/31 and this value to put in my chart. I tried a loop code but no success with that. Thanks Quote
Ace Master Posted November 10, 2003 Author Posted November 10, 2003 load multiple files ?? hi again. Nobody knows how to load multiple files to an array? I whant just a simple code for loading the 3 files into an array. I will make the rest by myself, but I can't make this work :( thanks Quote
Ace Master Posted November 10, 2003 Author Posted November 10, 2003 I made my loading for all the files I need, but the problems is how I can put my info from the files into separate variables ? This because as you can see for put the info into ziua1 but when the next cicle ocur I will loose the previous data. How I can make a separate variables for each file I open and read ? thanks Public Sub grafic_for(ByVal x) For i As Integer = 0 To x ziua = Format(DatTim1.AddDays(-i), "dd") month = Format(DatTim1.AddDays(-i), "MM") year = Format(DatTim1.AddDays(-i), "yyyy") cale_finala = cale + ziua + month + year + ext Dim my As IO.StreamReader my = IO.File.OpenText(cale_finala) Dim Line As Object Dim space1 As Object = " " Dim enter1 As Object Line = my.ReadToEnd my.Close() ziua1 = Line.Split(space1) Next End Sub Quote
Voca Posted November 10, 2003 Posted November 10, 2003 I myself have never loaded more than one file, but I heard it schould be possible by this little Listing: Dim ff(x) as Integer 'x is the number of files you want to open Dim i as Integer For i = 0 to ff.GetUpperbound(0) ff(i) = freefile() FileOpen(ff(i), ....) 'I do not know all the parameters at the moment Next Via Wirteline(ff(i), ...) You can Add Values. Reading should work the same way. But I did not try yet. Plesse regard this more as a hint than as the solution to your problem. Voca Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.