1. Public Function ReadLineInFile(ByVal File As String, ByVal Line As Long) As String Const lngForReading As Long = 1& Dim objFileSystemObject As Object Dim objFile As Object Dim lngLine As Long
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject") Set objFile = objFileSystemObject.OpenTextFile(File, lngForReading&)
On Error Resume Next
For lngLine& = 0& To Line& - 2& Call objFile.SkipLine Next lngLine&
ReadLineInFile$ = objFile.ReadLine$
Call objFile.Close Set objFile = objFileSystemObject.OpenTextFile(File, lngForReading&) Set objFileSystemObject = CreateObject("Scripting.FileSystemObject") End Function
1. Public Function ReadLineInFile(ByVal File As String, ByVal Line As Long) As String Const lngForReading As Long = 1& Dim objFileSystemObject As Object Dim objFile As Object Dim lngLine As Long
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject") Set objFile = objFileSystemObject.OpenTextFile(File, lngForReading&)
On Error Resume Next
For lngLine& = 0& To Line& - 2& Call objFile.SkipLine Next lngLine&
ReadLineInFile$ = objFile.ReadLine$
Call objFile.Close Set objFile = Nothing Set objFileSystemObject = Nothing End Function
The DatePart function syntax has these named arguments:
Part Description interval Required. String expression that is the interval of time you want to return. date Required. Variant (Date) value that you want to evaluate. firstdayofweek Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed. firstweekofyear Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.
Settings
The interval argument has these settings:
Setting Description yyyy Year q Quarter m Month y Day of year <--------------------------- d Day w Weekday ww Week h Hour n Minute s Second
The firstdayofweek argument has these settings:
Constant Value Description vbUseSystem 0 Use the NLS API setting. vbSunday 1 Sunday (default) vbMonday 2 Monday vbTuesday 3 Tuesday vbWednesday 4 Wednesday vbThursday 5 Thursday vbFriday 6 Friday vbSaturday 7 Saturday
The firstweekofyear argument has these settings:
Constant Value Description vbUseSystem 0 Use the NLS API setting. vbFirstJan1 1 Start with week in which January 1 occurs (default). vbFirstFourDays 2 Start with the first week that has at least four days in the new year. vbFirstFullWeek 3 Start with first full week of the year.
</Snip>
Jeg vil dog udvide til, at den skal bruges således:
lngDayOfYear = DataPart("y", Date, vbUseSystem, vbUseSystem), da vbUseSystem ikke er default værdier. Jeg ved dog ikke, om de har nogen indvirkning på denne datepart parameter.
Så vidt jeg kan se, har du fået 20 ud af 30 points.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.