|
-
Aug 23rd, 2001, 05:09 PM
#1
Thread Starter
Hyperactive Member
Have a look at my code pls
Take a peek
Can anybody tell me how hopeless my attempt at this is? Is my code even close to doing what I want it to? I'm trying to graph a single line ( latitude vs. time ) the (x,y) coordinates are stored in two very large text files. Here is my code:
code:--------------------------------------------------------------------------------
Private Sub cmdGraphB_Click()
Dim tmp1 As String
Dim tmp2 As String
Dim timeCtr As Long
dim i as Long
Dim the_time As Double
Dim the_latitude As Double
Dim Values() As Single
Dim NumPoints As Integer
Open "C:\Unzip Next Step\R1 Files\R1Time.txt" For Input As #1
Open "C:\Unzip Next Step\R1 Files\R1Latitude.txt" For Input As #2
timeCtr = 0
Do While Not EOF(1)
Line Input #1, tmp1
tmp1 = CLng(tmp1)
timeCtr = timeCtr + 1
Line Input #2, tmp2
tmp2 = CLng(tmp2)
the_latitude = tmp2
Values(i, 1) = timeCtr
Values(i, 2) = the_latitude
Loop
Close #2
Close #1
MSChart1.chartType = VtChChartType2dXY
MSChart1.ColumnCount = 2
MSChart1.ChartData = Values
End Sub
--------------------------------------------------------------------------------
Thanks
-
Aug 23rd, 2001, 05:32 PM
#2
Frenzied Member
There are a few problems. First, your array (Values() ) needs to
be dimensioned to a size. The size would be the number of
values you read from the file. It sounds like you don't know that
in advance, but that is not a big problem. Also the array is Single
yet you are storing two Longs in it (CLng(tmp1) and CLng(tmp2)).
It should be one or the other. With a Sinlge you get digits to the
right of the decimal, with a Long you don't.
When you store values in the array, the first part - 'i' - never
changes in your code (Values(i, 2) = the_latitude ), however,
timeCtr does, so you should be using that (Values(2, timeCtr) =
the_latitude )
If you want numbers to the right change Clng to CSng
Code:
Private Sub cmdGraphB_Click()
Dim sTemp As String
Dim lCounter As Long
Dim Values() As Single
Open "C:\Unzip Next Step\R1 Files\R1Time.txt" For Input As #1
Open "C:\Unzip Next Step\R1 Files\R1Latitude.txt" For Input As #2
lCounter = 0
Do While Not EOF(1)
If lCounter = 0 Then
ReDim Values(2, 25)
ElseIf lCounter Mod 25 = 0 Then
ReDim Preserve Values(2, UBound(Values, 2) + 25)
End If
Line Input #1, sTemp
Values(1, lCounter) = CLng(sTemp)
Line Input #2, sTemp
Values(2, lCounter) = CLng(sTemp)
lCounter = lCounter + 1
Loop
Close #2
Close #1
MSChart1.chartType = VtChChartType2dXY
MSChart1.ColumnCount = 2
MSChart1.ChartData = Values
End Sub
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Aug 23rd, 2001, 05:58 PM
#3
Thread Starter
Hyperactive Member
Thanks a lot for the reply Greg. Do you know how many (x, y) sets this can handle.... I think my files may be much to large (I've run into that a lot with this app ). I'm looking at about 1.5 million (x,y) sets . Is this do-able?
-
Aug 23rd, 2001, 07:03 PM
#4
Frenzied Member
The real question I would think, would be what can you discern from looking at a graph with 1.5 million lines on it. That is a lot of data to view at one time. I don't know what the limitations of MSChart are, but it is my understanding that arrays are limited to the amount of memory available to them.
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Aug 24th, 2001, 10:31 AM
#5
Thread Starter
Hyperactive Member
Hello,
I'm getting a runtime error '13' "type mismatch"
on the line in bold in this code. I have cropped the input files
considerably, as my main concern right now is just getting a graph up. Files contain about 10% of the (x,y) points to be plotted as before (I know this is still a lot... ablout 100k points).
Here is the code:
Private Sub cmdGraphB_Click()
Dim sTemp As String
Dim lCounter As Long
Dim Values() As Single
Open "C:\Unzip Next Step\R1 Files\R1Time.txt" For Input As #1
Open "C:\Unzip Next Step\R1 Files\R1Latitude.txt" For Input As #2
lCounter = 0
Do While Not EOF(1)
If lCounter = 0 Then
ReDim Values(2, 25)
ElseIf lCounter Mod 25 = 0 Then
ReDim Preserve Values(2, UBound(Values, 2) + 25)
End If
Line Input #1, sTemp
Values(1, lCounter) = CLng(sTemp)
Line Input #2, sTemp
Values(2, lCounter) = CLng(sTemp)
lCounter = lCounter + 1
Loop
Close #2
Close #1
MSChart1.chartType = VtChChartType2dXY
MSChart1.ColumnCount = 2
MSChart1.ChartData = Values
End Sub
Thank you for your time,
Paul Grimes
-
Aug 24th, 2001, 10:32 AM
#6
Good Ol' Platypus
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 24th, 2001, 10:35 AM
#7
Thread Starter
Hyperactive Member
It gives the same error msg using CLng() or CSng().
thx,
Paul
-
Aug 24th, 2001, 03:39 PM
#8
Frenzied Member
That should be
Code:
Line Input #1, sTemp
Values(0, lCounter) = CLng(sTemp)
Line Input #2, sTemp
Values(1, lCounter) = CLng(sTemp)
My bad...sorry.
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|