Scott
Tue Jun 28 23:16:05 CDT 2005
No need to pass your string arguments ByRef. Strings are classes and
therefore are Reference Types. If you pass a reference type ByRef, it is
actually slightly LESS efficient than passing a reference type ByVal. Both
will have the same result.
<thomasp@msala.net> wrote in message
news:42bee27d$0$11816$b9f67a60@news.newsdemon.com...
> For those they might be interested, this is what I ended up with.
> Criticism
> welcome.
>
> Thomas
>
> Public Sub subImportLCMR(ByVal intCounter As Integer, ByVal strImportDate
> As
> String, _
> ByVal intMaxID As Integer, ByRef bolSuccessful
> As Boolean, _
> ByRef strFirstDTG As String, ByRef strLastDTG
> As String, _
> ByRef strSummary As String)
>
> Dim intStart As Integer = 0
> Dim intNumRecords As Integer
> Dim intDistance As Integer
> Dim intDirection As Integer
>
> Dim datImportDate As Date
> Dim datRecordDate As Date
>
> Dim diffEast As Double
> Dim diffNorth As Double
>
>
>
> intSuccessful = 0
> bolSuccessful = True
> strSummary = ""
>
> 'Heading for summary
> strSummary = "Date" & vbTab & vbTab & "Time" & vbTab & "POO" &
> vbTab
> & vbTab & "POO Alt" & vbTab & "POI" & vbTab & vbTab & _
> "POI Alt" & vbTab & "Distance" & vbTab &
> "Direction" & vbCr
>
> 'Save the original value of intCounter as the number of records in
> aryLCMRData
> intNumRecords = intCounter
>
> 'set the date variable for what record the import should start on
> datImportDate = CDate(strImportDate)
>
> 'This If Then loop determines where the import should start based
> on
> the above date
> 'it cycles through the aryLCMRData until it comes to the first
> record with a date/time
> 'group newer than or equal to the given date/time group
> If Len(strImportDate) > 0 Then
> For intCounter = 0 To intCounter - 1
> datRecordDate = CDate(aryLCMRData(intCounter, 1) & " " &
> aryLCMRData(intCounter, 0))
> If datRecordDate >= datImportDate Then
> intStart = intCounter
> Exit For
> End If
> Next
> End If
>
> 'This For Next loop will start
> For intCounter = intStart To intNumRecords - 1
>
> 'Get the distance and the direction
> intDistance = Distance(aryLCMRData(intCounter, 2),
> aryLCMRData(intCounter, 4), diffEast, diffNorth)
> intDirection = Direction(diffNorth, diffEast)
>
> 'up the ID by one
> intMaxID = intMaxID + 1
>
> Dim strSQL As String = "SELECT * FROM LCMR"
> Dim strCON As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=" & _
> strAppPath & "TAM.mdb;Persist
> Security Info = False"
>
> Dim con As New OleDb.OleDbConnection(strCON)
> Dim da As New OleDb.OleDbDataAdapter(strSQL, con)
> Dim cb As New OleDb.OleDbCommandBuilder(da)
> Dim ds As New DataSet
> Dim newRow As DataRow
>
> Try
> da.FillSchema(ds, SchemaType.Source, "LCMR")
> newRow = ds.Tables("LCMR").NewRow()
>
> newRow("ID") = intMaxID
> newRow("ATime") = "#" & aryLCMRData(intCounter, 0) & "#"
> newRow("ADate") = "#" & aryLCMRData(intCounter, 1) & "#"
> newRow("POO") = aryLCMRData(intCounter, 2)
> newRow("POO_Alt") = Val(aryLCMRData(intCounter, 3))
> newRow("POI") = aryLCMRData(intCounter, 4)
> newRow("POI_Alt") = Val(aryLCMRData(intCounter, 5))
> newRow("Distance") = intDistance
> newRow("Direction") = intDirection
> newRow("Target_NO") = ""
> newRow("Weapon_Type") = ""
> newRow("Confirmed") = 0
>
> ds.Tables("LCMR").Rows.Add(newRow)
>
> If da.Update(ds, "LCMR") Then
>
> 'Get the first successful DTG imported
> If Len(strFirstDTG) < 1 Then
> strFirstDTG = Left(aryLCMRData(intCounter, 1) & " "
> & aryLCMRData(intCounter, 0), 15)
> End If
>
> 'Get the last DTG imported
> strLastDTG = Left(aryLCMRData(intCounter, 1) & " " &
> aryLCMRData(intCounter, 0), 15)
>
> 'Add one to the successful import record counter
> intSuccessful = intSuccessful + 1
>
> 'Create import summary
> strSummary = strSummary & aryLCMRData(intCounter, 1) &
> vbTab & vbTab & aryLCMRData(intCounter, 0) & vbTab & _
> aryLCMRData(intCounter, 2) &
> vbTab & aryLCMRData(intCounter, 3) & vbTab & _
> aryLCMRData(intCounter, 4) &
> vbTab & aryLCMRData(intCounter, 5) & vbTab & _
> intDistance & vbTab &
> intDirection & vbCr
>
> End If
>
> da.Dispose()
> ds.Dispose()
>
> If gfrmImport.prgProgress.Value + 1 <
> gfrmImport.prgProgress.Maximum Then
> gfrmImport.prgProgress.Value =
> gfrmImport.prgProgress.Value + 1
> Else
> gfrmImport.prgProgress.Value =
> gfrmImport.prgProgress.Maximum
> End If
>
>
> Catch oException As OleDbException
> MessageBox.Show(oException.Message)
> bolSuccessful = False
> Catch oException As Exception
> MessageBox.Show(oException.Message)
> bolSuccessful = False
>
> End Try
>
> Next
>
> End Sub
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> ------->>>>>>
http://www.NewsDemon.com<<<<<<------
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access