Approach Script to VB Script

zumzumzoom

New member
Joined
Jul 1, 2008
Messages
1
Programming Experience
Beginner
I need to change my Lotus Approach script to VB. I am new at using VB and would like some help getting it started. Basically this is a script that is used with a dbf file with time clock information in it. Any help would be appreciated. Thanks

Approach Script

Option Compare Database

Sub calc48hours()
Dim C As New Connection
Dim Q As New Query
Dim RS As New Recordset


Dim adjustments As Integer
Dim whalfprem As Integer
Dim wcateg(10) As String
Dim wtotal(10) As Single
Dim windes As Integer
Dim whpremhrs As Single
Dim wadjusthrs As Single


Rem When 2-3-2 schedule starts again review department selection below

Dim totalminutes As Integer
If C.Connect("dBase IV") Then
Set Q.Connect = C
Q.tablename = "c:\totals.mdf"
Q.SQL = "Select * FROM ""c:\totals.mdf"" Totals WHERE(Totals.TTYPE = 'I' and Totals.LENT1 <> '00023' and Totals.Lent1 <> '00021')"
Set RS.Query = Q
Print "48 Hour calculation program is started..."
If (RS.Execute) Then
RS.Firstrow
Do
whalfprem = 0
totalminutes = 0
windex = 1
wcateg(1) = RS.Getvalue("CATEG_1")
wtotal(1) = RS.Getvalue("TOTAL_1")
wcateg(2) = RS.Getvalue("CATEG_2")
wtotal(2) = RS.Getvalue("TOTAL_2")
wcateg(3) = RS.Getvalue("CATEG_3")
wtotal(3) = RS.Getvalue("TOTAL_3")
wcateg(4) = RS.Getvalue("CATEG_4")
wtotal(4) = RS.Getvalue("TOTAL_4")
wcateg(5) = RS.Getvalue("CATEG_5")
wtotal(5) = RS.Getvalue("TOTAL_5")
wcateg(6) = RS.Getvalue("CATEG_6")
wtotal(6) = RS.Getvalue("TOTAL_6")
wcateg(7) = RS.Getvalue("CATEG_7")
wtotal(7) = RS.Getvalue("TOTAL_7")
wcateg(8) = RS.Getvalue("CATEG_8")
wtotal(8) = RS.Getvalue("TOTAL_8")
wcateg(9) = RS.Getvalue("CATEG_9")
wtotal(9) = RS.Getvalue("TOTAL_9")
wcateg(10) = RS.Getvalue("CATEG_10")
wtotal(10) = RS.Getvalue("TOTAL_10")
Do While windex < 11
If wcateg(windex) = "REG" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "HOLIDAY" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "PERHOL" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "VACPAY" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "BREV" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "OTHPAY" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "UN-NP" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "COMPAY" Then
totalminutes = totalminutes + wtotal(windex)
ElseIf wcateg(windex) = "HALFPREM" Then
whalfprem = wtotal(windex)
End If
windex = windex + 1
Loop
If totalminutes > 2880 Then
adjustmins = ((totalminutes - 2880) * 2) + 480
If adjustmins > whalfprem Then
whpremhrs = whalfprem / 60
wadjusthrs = adjustmins / 60
Print "Employee:"; RS.Getvalue("EMPNUM"); "; Recommended HALFPREM="; wadjusthrs; "; Current"; HALFPREM - " whpremhrs"
End If
Else
If totalminutes > 2400 Then
adjusmins -(totalminutes - 2400)
If adjusmins > whalfprem Then
whpremhrs = whalfprem / 60
wadjusthrs -adjustmins / 60
Print "Employee:"; RS.Getvalue("EMPNUM"); ";Recommended HALFPREM="; wadjushrs; ";Current HALFPREM="; whpremhrs
End If
End If
End If
Loop While RS.Nextrow
End If
End If
Print "48 Hour calculation program is ended!!!"
C.Disconnect
End Sub
Sub Vac_REG()
Dim C As New Connection
Dim Q As New QueryDef
Dim RS As New ResultSet

Dim Totalregmin As Integer
Dim Totalvacmin As Integer

Dim wcateg(10) As String
Dim wtotal(10) As Single
Dim windex As Integer

If C.ConnectTO("dbase IV") Then
Set Q.Connection = C
Q.tablename = "C:\Totals.mdf"
Q.SQL = "select * FROM ""C:\Totals.mdf"" Totals WHERE(TotalsTTYPE='D')"
Set RS.Query = Q
Print "Vac/Regular time edit validation started....."
If (RS.Execute) Then
RS.Firstrow
Do
windex = 1
Totalregmin = 0
Totalvacmin = 0
wcateg(1) = RS.Getvalue("CATEG_1")
wtotal(1) = RS.Getvalue("TOTAL_1")
wcateg(2) = RS.Getvalue("CATEG_2")
wtotal(2) = RS.Getvalue("TOTAL_2")
wcateg(3) = RS.Getvalue("CATEG_3")
wtotal(3) = RS.Getvalue("TOTAL_3")
wcateg(4) = RS.Getvalue("CATEG_4")
wtotal(4) = RS.Getvalue("TOTAL_4")
wcateg(5) = RS.Getvalue("CATEG_5")
wtotal(5) = RS.Getvalue("TOTAL_5")
wcateg(6) = RS.Getvalue("CATEG_6")
wtotal(6) = RS.Getvalue("TOTAL_6")
wcateg(7) = RS.Getvalue("CATEG_7")
wtotal(7) = RS.Getvalue("TOTAL_7")
wcateg(8) = RS.Getvalue("CATEG_8")
wtotal(8) = RS.Getvalue("TOTAL_8")
wcateg(9) = RS.Getvalue("CATEG_9")
wtotal(9) = RS.Getvalue("TOTAL_9")
wcateg(10) = RS.Getvalue("CATEG_10")
wtotal(10) = RS.Getvalue("TOTAL_10")
Do While windex < 11
If wcateg(windex) = "REG" Then
Totalregmin = Totalregmin + wtotal(windex)
ElseIf wcateg(windex) = "VACPAY" Then
Totalvacmin = Totalvacmin + wtotal(windex)
End If
windex = windex + 1
Loop
If Totalregmin > 0 Then
If Totalvacmin > 0 Then
Print "Employee:"; RS.Getvalue("EMPNUM"); "; Has vacation and REG hours in same day - beware...."

End If
End If
Loop While RS.Nextrow
End If
End If
C.Disconnect
Print "Vac/Regular time edit validation is ended!!!!"

End Sub
 
Posted in the wrong section, and not using code tags. I doubt anyone will take a look at it, sorry
 

Latest posts

Back
Top