A
Asif
Hi everyone!
I was playing with some code from a tutorial and was a bit perplexed with the result. Can someone please explain what's going on?
The following data are in a file:
-------------------
This is some test data
"x-values","y-values"
0.0,1.4
1.0,4.3
2.0,6.2
3.0,5.1
4.0,6.4
5.0,7.7
6.0,7.9
7.0,8.4
8.0,7.3
9.0,6.2
10.0,9.1
=======================================
'Following code reads those data from the file
Dim xvals(100) As Single
Dim yvals(100) As Single
Dim npts As Integer
Sub GetDataFromDisk()
Open ThisWorkbook.Path + "\Task2.2.dat" For Input As #1
Line Input #1, Title$
Cells(1, 1) = Title$
Input #1, xtit$, ytit$
Cells(2, 1) = xtit$
Cells(2, 2) = ytit$
npts = 0
While Not EOF(1)
npts = npts + 1
Input #1, xvals(npts), yvals(npts)
Cells(2 + npts, 1) = xvals(npts)
Cells(2 + npts, 2) = yvals(npts)
Wend
Close #1
End Sub
========================
And this is what I got (look at the y-values):
x-values y-values
0 1.39999997615814
1 4.30000019073486
2 6.19999980926513
3 5.09999990463256
4 6.40000009536743
5 7.69999980926513
6 7.90000009536743
7 8.39999961853027
8 7.30000019073486
9 6.19999980926513
10 9.10000038146972
I was playing with some code from a tutorial and was a bit perplexed with the result. Can someone please explain what's going on?
The following data are in a file:
-------------------
This is some test data
"x-values","y-values"
0.0,1.4
1.0,4.3
2.0,6.2
3.0,5.1
4.0,6.4
5.0,7.7
6.0,7.9
7.0,8.4
8.0,7.3
9.0,6.2
10.0,9.1
=======================================
'Following code reads those data from the file
Dim xvals(100) As Single
Dim yvals(100) As Single
Dim npts As Integer
Sub GetDataFromDisk()
Open ThisWorkbook.Path + "\Task2.2.dat" For Input As #1
Line Input #1, Title$
Cells(1, 1) = Title$
Input #1, xtit$, ytit$
Cells(2, 1) = xtit$
Cells(2, 2) = ytit$
npts = 0
While Not EOF(1)
npts = npts + 1
Input #1, xvals(npts), yvals(npts)
Cells(2 + npts, 1) = xvals(npts)
Cells(2 + npts, 2) = yvals(npts)
Wend
Close #1
End Sub
========================
And this is what I got (look at the y-values):
x-values y-values
0 1.39999997615814
1 4.30000019073486
2 6.19999980926513
3 5.09999990463256
4 6.40000009536743
5 7.69999980926513
6 7.90000009536743
7 8.39999961853027
8 7.30000019073486
9 6.19999980926513
10 9.10000038146972