Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Need Help Converting Script from Approach to VBS

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62044
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need Help Converting Script from Approach to VBS
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Need Help Converting Script from Approach to VBS - 7/1/2008 12:13:11 AM   
  zumzumzoom

 

Posts: 1
Score: 0
Joined: 7/1/2008
Status: offline
We are leaving our lotus applications and switching to all Microsoft products.  I need help getting this approach script to work in VBS.  The script is similar to VB but has some differences.  Any help would be appreciated.  Thanks


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
 
               
       
                       
                       
                       
                   
                   
                       
                        
                       
                   
                   
           
   
 
 
Post #: 1
 
 RE: Need Help Converting Script from Approach to VBS - 7/6/2008 4:13:08 AM   
  dm_4ever


Posts: 2432
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
For starters... you don't define the type of variables in vbscrip so you can get rid of any

As New XXX
As XXXX

Secondly, search for CreateObject and ADODB for your database connection

Everything else looks similar and you should be able to easily change it...Print does not exist in VBScript but you can use WScript.Echo or MsgBox

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zumzumzoom)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need Help Converting Script from Approach to VBS Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts