Line 1: |
Line 1: |
| | | |
− | ==Code==
| + | ==Sectors== |
− | <source>
| + | ==Air Freight== |
− | ' The advantage of correctly typing fso as FileSystemObject is to make autocompletion
| + | {| {{Table|sort|class=left}} |
− | ' (Intellisense) work, which helps you avoid typos and lets you discover other useful
| + | ! Symbol !! Security Name !! Exchange !! ETF !! Chart |
− | ' methods of the FileSystemObject
| + | |- |
− | Dim fso As FileSystemObject
| + | ! AIRT |
− | Set fso = New FileSystemObject
| + | | Air T, Inc. - Common Stock |
− | Dim fileStream As TextStream
| + | | Q |
− | ' Here the actual file is created and opened for write access
| + | | N |
− | Set fileStream = fso.CreateTextFile(filePath)
| + | | {{GraphChart|width=200|height=50|xAxisTitle=Days|yAxisTitle=Market Price|y1Title=High|y2Title=Low|legend=Legend|type=line |
− | ' Write something to the file
| + | |x= 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,|y1= 18.56, 18.6342, 19.1148, 18.53, 18.5, 18.5, 18.5, 18.3899, 17.6835, 16.28, 15.69, 13.07, 13.4777, 12.031, 12.93, 14.94, 12.0098, 10.89, 11.85, 11.56, 10.95, 13.5, 13.77, 12.5,|y2= 18.5, 18.5, 18.5, 18.5, 18.5, 16.915, 17.09, 18.3899, 16.75, 15, 15.4381, 10.75, 11.75, 10.5, 10.45, 12.65, 10.55, 9.51, 9.41, 10.5, 10.82, 12, 12.51, 12.44, |
− | Dim db As Database
| + | |colors=#0000aa,#ff8000}} |
− | Dim MyRS As DAO.Recordset
| + | |- |
− | Dim MyRS2 As DAO.Recordset
| + | ! AIRTP |
− | Dim linex As String, liney1 As String, liney2 As String
| + | | Air T, Inc. - Trust Preferred Securities |
− | Dim nCounter As Integer
| + | | Q |
− | Set db = CurrentDb()
| + | | N |
− | Set MyRS = db.OpenRecordset("NASDAQ")
| + | | {{GraphChart|width=200|height=50|xAxisTitle=Days|yAxisTitle=Market Price|y1Title=High|y2Title=Low|legend=Legend|type=line |
− | Set MyRS2 = db.OpenRecordset("Daily_Trade")
| + | |x= 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,|y1= 24.99, 24.9794, 24.95, 24.9, 24.8, 24.9062, 24.5, 24.6, 24.6, 24.4625, 24.15, 23.91, 23.3855, 21.9894, 22.75, 20.35, 19.5, 20, 19.5, 19.1, 19, 19.5, 19.97, 19.13,|y2= 24.99, 24.92, 24.04, 24.744, 24.4, 24.68, 24.37, 24.5, 23.91, 23.91, 24.15, 22.25, 23, 21.85, 21.75, 20, 19.5, 18.2, 19, 19.1, 19, 19.26, 19.22, 18.01, |
− | MyRS.MoveFirst
| + | |colors=#0000aa,#ff8000}} |
− | '
| + | |- |
− | fileStream.WriteLine "==Sectors=="
| + | ! AIRTW |
− | fileStream.WriteLine "==" & Me.Sector & "=="
| + | | Air T, Inc. - Air T Funding Warrants to Purchase Trust Preferred |
− | fileStream.WriteLine "{| {{Table|sort|class=left}}"
| + | | Q |
− | fileStream.WriteLine "! Symbol !! Security Name !! Exchange !! ETF !! Chart"
| + | | N |
− | fileStream.WriteLine "|-"
| + | | {{GraphChart|width=200|height=50|xAxisTitle=Days|yAxisTitle=Market Price|y1Title=High|y2Title=Low|legend=Legend|type=line |
− | '
| + | |x= 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,|y1= .08, .0729, .0775, .07, .0702, .0701, .07, .0738, .1498, .07, .1889, .19, .0708, .15, .15, .1198, .12, .12, .0999, .0994, .0702, .0999,|y2= .069, .07, .0702, .07, .07, .07, .07, .07, .07, .07, .07, .07, .07, .07, .07, .07, .07, .085, .0995, .07, .07, .07, |
− | While Not MyRS.EOF
| + | |colors=#0000aa,#ff8000}} |
− | If MyRS("Sector") = Me.Sector Then
| + | |- |
− | fileStream.WriteLine "! " & MyRS("Symbol")
| + | ! ATSG |
− | fileStream.WriteLine "| " & MyRS("Security_Name")
| + | | Air Transport Services Group, Inc - Common Stock |
− | fileStream.WriteLine "| " & MyRS("Listing_Exchange")
| + | | Q |
− | fileStream.WriteLine "| " & MyRS("ETF")
| + | | N |
− | linex = "|x="
| + | | {{GraphChart|width=200|height=50|xAxisTitle=Days|yAxisTitle=Market Price|y1Title=High|y2Title=Low|legend=Legend|type=line |
− | liney1 = "|y1="
| + | |x= 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,|y1= 19.25, 17.93, 17.93, 18.12, 19.48, 18.47, 18, 17.23, 16.6, 16.49, 15.76, 14.84, 14.97, 15.05, 17.15, 17.83, 19.37, 20.24, 18.66, 18.99, 20.32, 19.48, 17.86, 18.95, 18.4, 18.97,|y2= 17.82, 16.41, 16.65, 16.77, 17.55, 17.245, 16.9, 16.41, 15.26, 15.64, 15, 13.51, 13.44, 13.2001, 13.99, 16.01, 17.14, 16.825, 16.41, 17.55, 18.31, 17.9401, 16.48, 16.75, 17.63, 17.42, |
− | liney2 = "|y2="
| + | |colors=#0000aa,#ff8000}} |
− | Set MyRS2 = db.OpenRecordset("SELECT * FROM Daily_Trade WHERE [Ticker] LIKE '" & MyRS("Symbol") & "';")
| + | |- |
− | If MyRS2.RecordCount > 0 Then
| + | |} |
− | fileStream.WriteLine "| " & "{{GraphChart|width=200|height=50|xAxisTitle=X|yAxisTitle=Y|legend=Legend|type=line"
| |
− | MyRS2.MoveFirst
| |
− | nCounter = 1
| |
− | While Not MyRS2.EOF
| |
− | linex = linex + Str(nCounter) & ","
| |
− | liney1 = liney1 + Str(MyRS2("High")) & ","
| |
− | liney2 = liney2 + Str(MyRS2("Low")) & ","
| |
− | MyRS2.MoveNext
| |
− | nCounter = nCounter + 1
| |
− | Wend
| |
− | fileStream.WriteLine linex & liney1 & liney2
| |
− | fileStream.WriteLine "|colors=#0000aa,#ff8000}}"
| |
− | End If
| |
− | MyRS2.Close
| |
− |
| |
− | fileStream.WriteLine "|-"
| |
− | End If
| |
− | MyRS.MoveNext
| |
− | Wend
| |
− |
| |
− | fileStream.WriteLine "|}"
| |
− | | |
− | | |
− | ' Close it, so it is not locked anymore
| |
− | fileStream.Close
| |
− |
| |
− | MyRS.Close
| |
− | Set db = Nothing
| |
− | Set MyRS = Nothing
| |
− | Set MyRS2 = Nothing
| |
− | ' Here is another great method of the FileSystemObject that checks if a file exists
| |
− | | |
− | | |
− | | |
− |
| |
− |
| |
− | </source>
| |
| | | |
| =Test 1= | | =Test 1= |