I have two databases: one holds the employee summary info, and the other one holds the serial number of the employee. On the database1, I have this agent that lets you import text file which contains updated records of the employee. But, In order for this agent to import a text file records successfully, the text file to be import must have a serial number record same as on the database2. It's working by the way, but I need to create a log when importing, still got no idea on how to resolve this. The logs(date imported, success and fail file imported) must be viewed on the fields. Can you help me out? Here's my code:
LoadAPMSAWDdoc
Sub LoadAPMSAWDdoc(Rname As Variant, directory As Variant, Datef As Variant)
Dim session As New NotesSession
Dim Tdoc As NotesDocumentCollection
Dim dateTime As New NotesDateTime ("01/01/2000")
'12/20/2005
Dim LocView As notesview
Dim LocDoc As NotesDocument
Dim subsidiary As String
Print "Loading APMSAWD - Award Information"
Set cdb = Session.CurrentDatabase
'12/20/2005
'StaffServerName = cdb.Server
Set LocView = cdb.GetView("LsvLocationProfile")
'02/07/2006
'Set LocDoc = LocView.getdocumentbykey(cdb.Server)
Set LocDoc = LocView.getfirstdocument
StaffServerName = LocDoc.z_ExtServer(0)
'SearchFormula$ = "Select Form = ""dfAward"" & #Date(s_Created) != #Date(#Today) "
If (ibmmy = True) And (ibmgdc = True) Then
SearchFormula$ = "Select Form = ""dfAward"" "
ElseIf (ibmmy = True) Then
SearchFormula$ = "Select Form = ""dfAward"" & I_GDCEmployee = ""IBM MY"""
Else
SearchFormula$ = "Select Form = ""dfAward"" & I_GDCEmployee = ""IBM GDC"""
End If
Set Tdoc = cdb.Search( SearchFormula$, DateTime, 0 )
If Tdoc.Count <> 0 Then
Call Tdoc.RemoveAll(True)
End If
'Get an unused file number
file_no% = Freefile()
Open (Trim(directory + "apmsawd.txt")) For Input As file_no%
Set db = Session.CurrentDatabase
Select Case Datef
Case "DMY" : Cdatf = "dd/mm/yyyy"
Case "MDY" : Cdatf = "mm/dd/yyyy"
Case "YMD" : Cdatf = "yyyy/mm/dd"
Case Else :
Print "LoadAPMSAWDdoc - Unknown system date format"
Exit Sub
End Select
Do While Not Eof(file_no%)
Line Input #file_no%, tmp
SerialNo = Trim$(Mid$(tmp,1,6))
AB = 0
For i = 29 To 0 Step -1
x1 = 8 + (i * 50)
x2 = 11 + (i * 50)
x3 = 41 + (i * 50)
x4 = 49 + (i * 50)
temp = Strconv(Trim$(Mid$(tmp,x2,30)),3)
If temp <> "" Then
Redim Preserve ACode(AB)
Redim Preserve ADes(AB)
Redim Preserve ADate(AB)
Redim Preserve AAmt(AB)
Acode(AB) = Trim$(Mid$(tmp,x1,3))
ADes(AB) = temp
If Trim$(Mid$(tmp,x3,8)) <> "" Then
AD1 = Setdate(Trim$(Mid$(tmp,x3,8)), "mm/dd/yy", Datef)
ADate(AB) = Cdat(Format(AD1, Cdatf))
'Datenumber ( Val(Trim$(Mid$(tmp,x3+6,2))) , Val(Trim$(Mid$(tmp,x3+3,2))) , Val(Trim$(Mid$(tmp,x3,2))) )
Else
ADate(AB) = Null
End If
AAmt(AB) = Val(Trim$(Mid$(tmp,x4,9)))
AB = AB + 1
Else
Exit For
End If
Next
subsidiary = Filter(CStr(SerialNo))
If (subsidiary = "AMY" And ammmy = True) Or (subsidiary = "ADC" And aaadc = True) Then
Set doc = New NotesDocument(db)
doc.Form = "dfAward"
doc.E_StaffSerialNo = SerialNo
doc.I_GDCEmployee = subsidiary
If AB = 0 And Trim$(Mid$(tmp,1461,30)) = "" Then
Redim Preserve ACode(AB)
Redim Preserve ADes(AB)
Redim Preserve ADate(AB)
Redim Preserve AAmt(AB)
ACode(0) = ""
ADes(0) = ""
ADate(0) = Null
AAmt(0) = Null
End If
doc.E_AwardType = ADes
doc.E_AwardDate = ADate
doc.E_AwardAmt = AAmt
doc.G_AuthorDisp = Rname
doc.s_created = Now
Call doc.Save (True, True)
End If
Loop
Close file_no%
Print "Award information imported"
End Sub
I'm sorry if I only posted some functions coz my code is too long and can't fit here.
First of all: It is VERY bad practice, to permanently delete all documents that match a search criteria just to directly afterwards add them back.
Deletion stubs will explode and this database will become slower and slower and at some point will not be usable anymore.
Better build a key to identify the document, get the document using the key and then update if necessary...
I usually build a list with all keys / unids (or documents, if there are not to much of them) and remove any document found in the "source" (text document in your case) from that list after processing.
Any document left in the list after running through the import file can be deleted...
Dim lstrUnids List as String
Set doc = Tdoc.GetFirstDocument()
While not doc is Nothing
lstrUnids( doc.E_StaffSerialNo(0) ) = doc.UniversalID
set doc = TDoc.GetNextDocument(doc)
Wend
But now back to your Question:
To write a simple Log you can use the NotesLog- Class. You can either log to a database (Template: Agent Log ), log to a mail or log to the Agents log (complicated to read) or even to a file.
Just do it like this:
Dim agLog as New NotesLog( "MyImportLog" )
Call agLog.OpenNotesLog( Server , logdbPath )
...
Call agLog.LogMessage( "Award information imported" )
...
Call agLog.Close() 'IMPORTANT !!!!
Related
QUESTION
I'm using VBA for retrieving data from SAP via BAPI. What RFC should I use, and how, to retrieve PO details at the "each SIZE for each ITEM" level.
EXAMPLE
In this screenshot you see that the PO includes 3 ITEMs. Each of these ITEMs includes several SIZEs/EANs. And for each of the SIZEs/EANs, the specific QUANTITIES are indicated
I want to retrieve this data into Excel. So I create all the needed objects for working with SAP, connect to BAPI_PO_GETITEMS, fill in PURCHASEORDER-parameter, indicate the table PO_ITEMS:
Option Explicit
Public Functions As SAPFunctionsOCX.SAPFunctions
Private LogonControl As SAPLogonCtrl.SAPLogonControl
Private objConnection As SAPLogonCtrl.Connection
Dim Func As SAPFunctionsOCX.Function
Public eNUMBER_OF_ENTRIES As SAPFunctionsOCX.Parameter
Public tENTRIES As SAPTableFactoryCtrl.Table
Public TableFactory As SAPTableFactory
Sub BAPI_PO_GETDETAIL()
Dim i As Integer, j As Integer
Dim retcd As Boolean
Dim SilentLogon As Boolean
Set LogonControl = CreateObject("SAP.LogonControl.1")
Set Functions = CreateObject("SAP.Functions")
Set TableFactory = CreateObject("SAP.TableFactory.1")
Set objConnection = LogonControl.NewConnection
SilentLogon = True
'Use the below block to hardcode system connection and connect automatically
objConnection.Client = ""
objConnection.ApplicationServer = ""
objConnection.Language = ""
objConnection.User = ""
objConnection.Password = ""
objConnection.System = ""
objConnection.SystemNumber = ""
'Logging into SAP
If objConnection.Logon(0, SilentLogon) Then
'Logon was successful
MsgBox "Logged on!"
'Create an object to call the RFC FM
Functions.Connection = objConnection
'Actual FM is added here
Set Func = Functions.Add("BAPI_PO_GETITEMS")
'Populate the importing parameters
Func.Exports("PURCHASEORDER").Value = "2845158864"
'Indicate the TABLE needed
Set tENTRIES = Func.Tables("PO_ITEMS")
'Call FM
Func.Call
'Dump onto the worksheet
For i = 1 To tENTRIES.ColumnCount 'cells(R, C)
cells(1, i).Value = tENTRIES.ColumnName(i)
Next i
For i = 1 To tENTRIES.RowCount
For j = 1 To tENTRIES.ColumnCount
cells(i + 1, j).Value = tENTRIES.Value(i, j)
Next j
Next i
Else
MsgBox "Not Logged on"
End If
End Sub
and get only 3 rows - for each of the 3 ITEMS, without the breakdown by SIZE/EAN:
How to retrieve the breakdown by SIZE/EAN, like on this screenshot:
Need help with vba code. please have look below on the code.
I want all the document in the view QA\QA Schedule which are in between (1sep2013 - 30sep2013). Here its not the document created date it the date which is taken form the column of the view so that i can pull the data in Excel
'Below is code which i have build what its doing is it is searching all the document and getting me the data which is taking lot of time. If can add a filter on the date we can do it little bit faster but i am not aware of the FT search syntax. how to use it on the view column. please help with this its really urgent.
Dim nSess As Object 'NotesSession
Dim sPwd As String
Dim strCnxn As String
Dim strSQL As String
Dim db As Object
Dim iviews As Object
Dim IView As Object
Set nSess = CreateObject("Lotus.NotesSession") 'New:{29131539-2EED-1069-BF5D- 00DD011186B7}
myUsername = ****
myPassword = ****
DSN1 = ("Driver={Lotus NotesSQL Driver (*.nsf)};Server=;Database=;Uid=" & myUsername & ";Pwd=" & myPassword & ";")
Call nSess.Initialize(sPwd)
Set db = nSess.GetDatabase("", "")
Set iviews = db.GetView("QA\QA Schedule")
iviews.AutoUpdate = False
Set IView = iviews.AllEntries
Set viewparentEntry = IView.Parent
Set viewEntry = viewparentEntry.GetFirstDocument
For i = 1 To IView.Count
Colval = viewEntry.ColumnValues()
For j = 0 To 20
If Colval(0) <> "2013 9" Then
Exit For
ElseIf Colval(18) >= "" Or Colval(18) <= "" Then
Exit For
ElseIf Colval(18) >= "09/01/2013" Or Colval(18) <= "09/30/2013" Then
Sheets("Sheet2").Cells(RowCount, colcount).Value = Colval(j)
colcount = colcount + 1
Else
Exit For
End If
Next
j = 0
colcount = 1
RowCount = RowCount + 1
Set viewEntry = viewparentEntry.GetNextDocument(viewEntry)
Next
There are a few options:
You could copy this view or change this view to only show documents between a certain date range, if appropriate.
You could call the FTSearch method on the database view. Some info on syntax for full text searches is here.
Here's an example that gets you a doc collection returned from a full text search on a view:
Dim db As Object
Dim iviews As Object
Dim IView As Object
Dim doc as NotesDocument
Set nSess = CreateObject("Lotus.NotesSession") 'New:{29131539-2EED-1069-BF5D- 00DD011186B7}
myUsername = ****
myPassword = ****
DSN1 = ("Driver={Lotus NotesSQL Driver (*.nsf)};Server=;Database=;Uid=" & myUsername & ";Pwd=" & myPassword & ";")
Call nSess.Initialize(sPwd)
Set db = nSess.GetDatabase("", "")
Set iviews = db.GetView("QA\QA Schedule")
iviews.AutoUpdate = False
iviews.FTSearch("[SomeDate] >= 9/1/2013 And [SomeDate] <= 9/30/2013")
Set doc = iviews.GetFirstDocument
While Not (doc Is Nothing)
// Do something here for each document
Set doc = iviews.GetNextDocument(doc)
Wend
I am receiving an excel(Book1.xls) file from the user and sometimes one of the worksheets name is XYZ and sometimes its name is XYZ1.
I am doing
Dim Conn,Rs
Set Conn = CreateObject("ADODB.Connection")
Conn.ConnectionTimeout = 10
Conn.CommandTimeout = 300
Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Book1.xls;Extended Properties=""Excel 12.0;HDR=No;IMEX=1"";"
Set RS = Conn.Execute("SELECT * FROM [XYZ$B1:B1]")
and when the worksheets name is XYZ1, the last line in the above code is blowing up with an error message:
The Microsoft Access database engine could not find the object 'XYZ$CB1:B1'. Make sure the object exists and that you spell its name and the path name correctly. If 'XYZ$CB1:B1' is not a local object, check your network connection or contact the server administrator.
Instead of the last line I would like to do something like
sheetNameString = Conn.Execute("SELECT Join(SheetName) from Book1.xls")
If InStr(sheetNameString,"XYZ1") Then
Set RS = Conn.Execute("SELECT * FROM [XYZ1$B1:B1]")
Else
Set RS = Conn.Execute("SELECT * FROM [XYZ$B1:B1]")
End If
Adding the following code after the conn.open worked for me:
Dim Cat, Tbl, Tabs
Cat = CreateObject("ADOX.Catalog")
Cat.ActiveConnection = Conn
Tabs = Cat.Tables
For Each Tbl In Tabs
'Tbl.Name holds the name
Next
You can use the "ADOX.Catalog" to get a list of the tables in a database:
Public Function getTableNames(oConn)
Dim aRVal : aRVal = Array()
Dim oCatalog : Set oCatalog = CreateObject( "ADOX.Catalog" )
Set oCatalog.ActiveConnection = oConn
Dim oTable
For Each oTable In oCatalog.Tables
ReDim Preserve aRVal( UBound( aRVal ) + 1 )
aRVal( UBound( aRVal ) ) = oTable.Name
Next
getTableNames = aRVal
End Function
If "XYZ1$" = getTableNames(Conn)(0) Then
Set RS = Conn.Execute("SELECT * FROM [XYZ1$B1:B1]")
Else
Set RS = Conn.Execute("SELECT * FROM [XYZ$B1:B1]")
End If
(not tested, assumes just one sheet/table, needs improvements (e.g. ReDim aRVal(oCatalog.Tables.Count - 1) instead of ReDim Preserve), not sure whether the trailing $ will be kept)
Another way:
Public Function getTableNames(oConn)
Const adSchemaTables = 20
Dim oRS : Set oRS = oConn.OpenSchema(adSchemaTables)
Dim aRVal : aRVal = Array()
Do Until oRS.EOF
ReDim Preserve aRVal(UBound(aRVal) + 1)
aRVal(UBound(aRVal)) = oRS.Fields("TABLE_NAME").Value
oRS.MoveNext
Loop
getTableNames = aRVal
End Function
I use the below script in querysave event of a form. The logic is when I save the form the sequence should get displayed in the view in two columns. like "115-" in one column and the sequence "00001", "00002", ... in the second column. The first two documents gets saved without any issue. When I save try to save 3rd and more documents, its displaying "00002" only every time after that. I am not able to identify what is the mistake. Can somebody help please.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim SESS As New NotesSession
Dim w As New NotesUIWorkspace
Dim uidoc As NotesUIdocument
Dim Doc As NotesDocument
Dim RefView As NotesView
Dim DB As NotesDatabase
Dim RefDoc As NotesDocument
Set DB = SESS.CurrentDatabase
Set uidoc = w.CurrentDocument
Set Doc = uidoc.Document
Set RefView = DB.GetView("System\AutoNo")
Dim approvedcnt As Integer
approvedcnt = Cint(source.fieldgettext("appcnt"))
If uidoc.EditMode = True Then
Financial_Year = Clng(Right$(Cstr(Year(Now)),3)) + 104
If Month(Now) >= 4 Then Financial_Year = Financial_Year + 1
DocKey = Cstr(Financial_Year)& "-"
New_No = 0
Set RefDoc = RefView.GetDocumentByKey(DocKey , True)
If Not(RefDoc Is Nothing) Then New_No = Clng(Right$(RefDoc.SETTLEMENT_NO(0),5))
New_No = New_No + 1
autono = DocKey & "-" & Right$("00000" & Cstr(New_No) ,5)
Application ="ST"
Latest_No = Application + autono
Doc.SETTLEMENT_NO = Latest_No
Doc.FinFlag="Finish"
Call SESS.SetEnvironmentVar("ENV_ST_NO",Right$("00000" & Cstr(DefNo&) ,5))
'Call uidoc.FieldSetText("SETTLEMENT_NO",Latest_No)
Call uidoc.Refresh
Else
Exit Sub
End If
get_ex_rate
get_cv_local
Call uidoc.FieldSetText("Flag1", "A")
If approvedcnt = 12 And uidoc.FieldGetText("STATUS") = "APPROVE" Then
Call uidoc.fieldsettext("Flag2", "B")
End If
Dim answer2 As Integer
answer2% = Msgbox("Do you want to save this document?", 1, "Save")
If answer2 = 1 Then
Print "Saving"
End If
If answer2 = 2 Then
continue=False
Exit Sub
End If
uidoc.Refresh
uidoc.close
End Sub
I imagine your call to GetDocumentByKey is getting the wrong document or not the next one in sequence. Make sure the view is sorted properly and perhaps call the refresh method on the view before calling GetDocumentByKey.
Hi there I'm not a developer and so am unaware of best practices. I created this to bypass manual data copying of log data. This agent is for a single feed which I'll copy and adjust for each additional one. For the specified feed it reads the log for the last time processed and number of files processed so far today and for yesterday. It also counts files in the input folder and reads the server's timezone. Each data item is separated by a comma for csv and emailed, which later is hosted on a website. Thanks for any constructive criticism.
Sub Initialize
Dim customername As String
Dim servername As String
Dim feedname As String
Dim alertthresholdinhours As Integer
Dim inputfeedpath As String
' Set for each feed
customername = "gRrhio"
servername = "gRrhioEdge2"
feedname = "FF Thompson ADT"
alertthresholdinhours = 6
inputfeedpath = "\\mhinec\elycon\data\adt\*.*"
' Counts files in input folder
Dim pathName As String, fileName As String
Dim inputfeedcounter As Integer
inputfeedcounter = 0
pathName$ = inputfeedpath
fileName$ = Dir$(pathName$, 0)
Do While fileName$ <> ""
inputfeedcounter = inputfeedcounter + 1
fileName$ = Dir$()
Loop
Dim entry As NotesViewEntry
Dim vc As NotesViewEntryCollection
Dim filesprocessed As Integer
Dim session As New NotesSession
Dim db As NotesDatabase
Dim newDoc As NotesDocument
Dim rtitem As NotesRichTextItem
Set db = session.CurrentDatabase
Dim view As NotesView
Set view = db.GetView( "Sessions\by Feed" )
Set newDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newDoc, "Body" )
Dim todaysdate As New NotesDateTime("Today")
Dim flag As Integer
Dim counter As Integer
Dim files As Integer
Dim errors As Integer
Dim lastdate As String
Dim lastdayran As String
Dim lasttime As String
Dim lasttimeran As String
Dim filesp As Integer
Dim lastdayfiles As Integer
Dim lastdaysfiles2 As Integer
Dim terrors As Integer
Dim lastdayerrors As Integer
lastdate = ""
lastdayran = ""
counter = 0
flag = 0
filesp = 0
lastdayfiles = 0
lastdaysfiles2 = 0
terrors = 0
lastdayerrors = 0
' Finds date for last time processed, counts files processed and errors
While flag = 0
Dim dateTime As New NotesDateTime(todaysdate.DateOnly)
Dim keyarray(1) As Variant
keyarray(0) = feedname
Set keyarray(1) = dateTime
Set vc = view.GetAllEntriesByKey(keyarray, False)
Set entry = vc.GetFirstEntry
If entry Is Nothing Then
Call todaysdate.AdjustDay(-1)
End If
While Not entry Is Nothing
files = 0
Forall colval In entry.ColumnValues
If counter = 9 Then
counter = 0
Elseif counter = 8 Then
counter = 9
Elseif counter = 7 Then
counter = 8
Elseif counter = 6 Then
errors = Cint(colval)
counter = 7
Elseif counter = 5 Then
counter = 6
Elseif counter = 4 Then
files = Cint(colval)
counter = 5
Elseif counter = 3 Then
counter = 4
Elseif counter = 2 Then
counter = 3
lasttime = colval
Elseif counter = 1 Then
counter = 2
lastdate = colval
Elseif counter = 0 Then
counter = 1
End If
End Forall
filesp = filesp + files
terrors = terrors + errors
Set entry=vc.GetNextEntry (entry)
flag = 1
Wend
Wend
lastdayfiles = filesp
lastdayerrors = terrors
lastdayran = lastdate
lasttimeran = lasttime
'Counts previous files processed
filesp = 0
terrors = 0
lastdate = ""
flag = 0
Call todaysdate.AdjustDay(-1)
While flag = 0
Dim dateTime2 As New NotesDateTime(todaysdate.DateOnly)
Dim keyarray2(1) As Variant
keyarray2(0) = feedname
Set keyarray2(1) = dateTime2
Set vc = view.GetAllEntriesByKey(keyarray2, False)
Set entry = vc.GetFirstEntry
If entry Is Nothing Then
Call todaysdate.AdjustDay(-1)
End If
While Not entry Is Nothing
files = 0
Forall colval In entry.ColumnValues
If counter = 9 Then
counter = 0
Elseif counter = 8 Then
counter = 9
Elseif counter = 7 Then
counter = 8
Elseif counter = 6 Then
counter = 7
Elseif counter = 5 Then
counter = 6
Elseif counter = 4 Then
files = Cint(colval)
counter = 5
Elseif counter = 3 Then
counter = 4
Elseif counter = 2 Then
counter = 3
Elseif counter = 1 Then
counter = 2
Elseif counter = 0 Then
counter = 1
End If
End Forall
filesp = filesp + files
Set entry=vc.GetNextEntry (entry)
flag = 1
Wend
Wend
lastdaysfiles2 = filesp
' Prints line of CSV into body of email
Call rtitem.AppendText ( customername )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( servername )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( datetime.timezone )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( lastdayran )
Call rtitem.AppendText ( " " )
Call rtitem.AppendText ( lasttimeran )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( lastdayfiles )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( lastdayerrors )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( lastdaysfiles2 )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( inputfeedcounter )
Call rtitem.AppendText ( ", " )
Call rtitem.AppendText ( alertthresholdinhours )
Call newDoc.Save( False, True )
newDoc.Subject = feedname
' Running from server line should be
'newDoc.SendTo = "Ecmon Feedcheck/Ecmonitor#ECMONITOR"
newDoc.SendTo = "AX1Forward Feedcheck/ACHQ#company.com"
newDoc.Send( False )
End Sub
For not being a developer, you can write a lot of code :)
If you are looking for some lessons to start becoming a good developer, then take Mitch's advice (from the comments) and break up this into subroutines. Lesson 1: There's definitely some repetitve code here, and it's always a good idea to put repetitive code into a method (function or subroutine) so it only exists once. The section that counts files processed and previous files processed looks similar and could probably be put into a routine like:
Function GetCountFilesProcessed() As Integer
'code here
End Function
However, you might even be able to save the need for that if I'm understanding your code correctly. Instead of doing that strange loop in the middle, it appears you're are trying to simply get a value from a column of a viewentry. Say you are interetsed in column 4's value. You can simply get at the value for the column you want by accessing it by index. For example, your files variable could be set directly to column 4's value by this line
files = Cint(entry.ColumnValues(4)) 'check this, it might be 3 if the array is zero based.
Anyway, bottom line is if this code works then you're off to a good start!
On more of the style side of things, I've always found it easier to maintain other people's code when they've
Declared Option 'Explicit' in the Declarations section
Declared variables from approximately higher to lower (eg, session before db before view before doc)
Prefixed notes objects with their type (docMail, dbMyDatabase, viewOutstandingInvoices)
Put all of the Declarations at the top before (helps finding the declaration when you come across a variable)
As others have mentioned, break it up into functions/subs where applicable.
Your comment about copying this agent for other instances of the same problem also raises a flag. Try to work out what is common between these agents and push those functions into a script library. This sort of thing saves a lot of time when maintaining the code as you don't need to think about in what way each agent is different (Eg. does my change apply to all instances of this agent, or just some of them?)
You want to decompose your code much more and ... one little thing. Instead of
while not item is nothing
which is a double negation and a popular brain bender.. write:
do until item is nothing
...
loop
This also allows you to break out of the loop with exit do
you can optimize both of your ForAll loops.
This is how the first one would look:
Forall colval In entry.ColumnValues
Select Case (counter)
Case 1: lastdate = colval
Case 2: lasttime = colval
Case 4: files = Cint(colval)
Case 6: errors = Cint(colval)
End Select
counter = (counter + 1) Mod 10
End Forall
This is how the second would one would look like:
Forall colval In entry.ColumnValues
if (counter = 4) Then files = Cint(colval)
counter = (counter + 1) Mod 10
End Forall
Just a note regarding this bit
While Not entry Is Nothing
files = 0
Forall colval In entry.ColumnValues
If counter = 9 Then
counter = 0
Elseif counter = 8 Then
counter = 9
....
As ken says you can get columnValues by using the entry.ColumnValues(x) method so interating through the values is un-needed. But; you could have done this
While Not entry Is Nothing
files = 0
counter = 0
Forall colval In entry.ColumnValues
counter = counter + 1
Select case counter
case 6
errors = Cint(colval)
.....
end select
Some good points already. To add to them if you have variables that share a common object then create a class. Add your variables to that class.
So instead of say:
Dim userFullName as String
Dim age as Integer
Dim addressLine1 as String
' ... etc.
You can have:
Class UserDetails
Dim fullName as String
Dim age as Integer
Dim addressLine1 as String
' ... etc
End Class
and reference:
Dim u as new UserDetails
u.fullName = "full name"
u.age = 22
u.addressLine1 = "1 main street"
The advantage of this is you can add methods to manipulate that data and you know the code relates to that object rather then hunting through your application.