0 penilaian0% menganggap dokumen ini bermanfaat (0 suara)
115 tayangan52 halaman
VBScript to C# - equivalent string functions A Cheat Sheet containing the VBScript string functions and their equivalent methods in C#. UBound() = yourArray.GetUpperBound(0) or yourArray.Length for one-dimesional arrays.
VBScript to C# - equivalent string functions A Cheat Sheet containing the VBScript string functions and their equivalent methods in C#. UBound() = yourArray.GetUpperBound(0) or yourArray.Length for one-dimesional arrays.
VBScript to C# - equivalent string functions A Cheat Sheet containing the VBScript string functions and their equivalent methods in C#. UBound() = yourArray.GetUpperBound(0) or yourArray.Length for one-dimesional arrays.
A Cheat Sheet containing the VBScript string functions and their equivalent methods in C#.
VBScript Description C# Equivalent InStr Returns the position of the first occurrence of one string within another. The search begins at the first character of the string IndexOf() InStrRev Returns the position of the first occurrence of one string within another. The search begins at the last character of the string - LCase Converts a specified string to lowercase ToLower() Left Returns a specified number of characters from the left side of a string SubString() Len Returns the number of characters in a string Length() LTrim Removes spaces on the left side of a string TrimStart() RTrim Removes spaces on the right side of a string TrimEnd() Trim Removes spaces on both the left and the right side of a string Trim() Mid Returns a specified number of characters from a string SubString() Replace Replaces a specified part of a string with another string a specified number of times Replace() Right Returns a specified number of characters from the right SubString() side of a string Space Returns a string that consists of a specified number of spaces PadLeft(), PadRight() StrComp Compares two strings and returns a value that represents the result of the comparison Compare(), Equals() String Returns a string that contains a repeating character of a specified length - StrReverse Reverses a string - UCase Converts a specified string to uppercase ToUpper() 1 2
Dim new_flag As Boolean Dim no_recs As Integer Dim clsobj As clsProd Dim User_Value As Byte Dim curr_col As Integer Dim isAscending As Boolean Dim Screen_Id As Long 'It is used to get the Value of ViewRights.SlNo Private Sub cmdExit_Click() Unload Me End Sub
Private Sub cmdView_Click() msflex.rows = 1 Call load_data End Sub
Private Sub cmdUpdate_Click()
If MsgBox("Are You Sure To Save?", vbYesNo + vbQuestion, mdiSSI.msgTxt) = vbYes Then Call save_record msflex.rows = 1 Call load_data txtEdit.Visible = False MsgBox "Record Saved .", vbInformation, mdiSSI.msgTxt End If End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer) ' If KeyCode = vbKeyF1 Then ' Call clsobj.show_help("TransInvStock.html") ' ElseIf KeyCode = vbKeyF5 Then ' If cmbStore.ListIndex = 0 Then ' If msflex.rows > 1 And msflex.Row > 0 Then ' Me.MousePointer = vbHourglass ' frmStockDetails.Left = 3500 ' frmStockDetails.Top = 3500 ' frmStockDetails.Show vbModal ' Me.MousePointer = 99 ' Else ' MsgBox "You have to select an Item from the displayed list to get Details!!!", vbInformation, mdiSSI.msgTxt ' End If ' Else ' MsgBox "Store option should be ALL in order to view Details!!!", vbInformation, mdiSSI.msgTxt ' End If ' End If End Sub Private Sub Form_Load() On Error Resume Next Dim main As Integer
Me.MousePointer = vbHourglass Set clsobj = New clsProd
'to get user rights If IsCurrYr = False Then User_Value = 4 clsobj.Get_Connection_mdi Else clsobj.Get_Connection ' User_Value = clsobj.Retrieve_Id("select mnustock from UserRights Where UserId=" & whoami) End If
'To get Screen Id ' Screen_Id = clsobj.Retrieve_Id("Select SlNo from ViewRights Where frmname='" & Replace(Me.namE, "'", "''") & "'")
'1 ' Call clsobj.Register_User_Log(Screen_Id, 1) '1 refers to user_Value as Read Only (Which manually set by Us)
Call init_msflex curr_col = 1
load_lstFieldsValues
msflex.AllowUserResizing = flexResizeColumns Me.MousePointer = vbDefault msflex.rows = 1 End Sub Private Sub Form_Unload(Cancel As Integer) Call clsobj.UnRegister_User_Log(Screen_Id) clsobj.Leave_Connection Set clsobj = Nothing End Sub Private Sub init_msflex() 'msflex.FormatString = " Sl.No |Item Code / Part No. | Qty After Reduction | Qty On Hand | Current Value | Value before Alteration" ''0 1 2 3 4 5 6 7 8 9 msflex.FormatString = " Sl.No | CustomerName | Inv.No. | Inv.Date. | Invoice Value | OverDueDays | C-FormRefNO | C-FormAmt | ReMarks | C- FormRefDate " msflex.WordWrap = True msflex.RowHeight(0) = 600 For i = 0 To 9 ' Call CellColor(0, i, vbWhite, vbRed) msflex.Row = 0 msflex.Col = i msflex.CellFontBold = True Next i ' msflex.ColWidth(5) = 0 ' msflex.ColWidth(4) = 0 End Sub Private Sub CellColor(ByVal ro As Integer, ByVal co As Integer, ByVal bg As ColorConstants, ByVal fg As ColorConstants) msflex.Row = ro msflex.Col = co msflex.CellBackColor = bg msflex.CellForeColor = fg End Sub Private Sub load_data() Dim i As Integer Dim tmpThisSession As Long Dim tmpdays As Integer Dim tmphrs As Long Dim tmpmins As Long Dim tmpCalc As Long Dim DispStr As String Dim tmpyear As Long
Select Case lstFields.ListIndex Case 0 'this is called from Manufacturing
clsobj.open_temp_rec ("Select * from DcInv where InvNo is not null and invno<> 'Nil' and IsFormC=true and CformValidation<>true and dcinv=false and invcancl=false order by invno") With clsobj.tmp_Rec If Not .EOF Then .MoveFirst While Not .EOF msflex.rows = msflex.rows + 1 msflex.Row = msflex.rows - 1 msflex.TextMatrix(msflex.Row, 0) = msflex.rows - 1 Dim CustName As String CustName = clsobj.Retrieve_Name("select Custname from customer where custid=" & .Fields("Custid") & " ") msflex.TextMatrix(msflex.Row, 1) = CustName msflex.TextMatrix(msflex.Row, 2) = .Fields("InvNo") msflex.TextMatrix(msflex.Row, 3) = .Fields("InvDate") msflex.TextMatrix(msflex.Row, 4) = .Fields("TotVal") ' msflex.TextMatrix(msflex.Row, 5) = .Fields("ProdQty") Dim prsdate As String prsdate = Now
' If tmpTotSEEDMins >= 9999999 Then ' Call update_rec("Update License set TotSEEDtime=0") ' End If
tmpCalc = Int(tmpThisSession / 60) 'this will give no. of hours of total SEED usage 525600
If tmpCalc >= 24 Then tmpdays = Int(tmpCalc / 24) 'this will give no. of days of total SEED usage DispStr = tmpdays & " Day(s) " tmpCalc = tmpCalc Mod 24 'this will give remaining no. of hours of SEED usage (after days calculation) DispStr = DispStr & tmpCalc & " Hour(s) "
'the follg. will 'overflow' run time error 'tmpmins = tmpTotSEEDMins - ((tmpdays * 24 * 60) + (tmpCalc * 60)) 'the error is because if result crosses beyond integer value 'check this in immediate window ? 57 * 24 * 60 (where 57 is the tmpdays)
'so the resolution is with precision (instead of 60 we made 60.0 or 60#) then converting to clng tmpmins = tmpThisSession - (CLng(tmpdays * 24 * 60#) + (tmpCalc * 60)) 'if we type 60.0, compiler assumes 60#
clsobj.open_temp_rec ("Select * from DcInv where InvNo is not null and invno<> 'Nil' and IsFormC=true and CformValidation<>true and dcinv=true and invcancl=false order by invno") ''("Select * from DcInv where InvNo is not null and invno<> 'Nil' and IsFormC=true and CformValidation<>true and dcinv=true and invcancl=false order by invno") With clsobj.tmp_Rec If Not .EOF Then .MoveFirst While Not .EOF msflex.rows = msflex.rows + 1 msflex.Row = msflex.rows - 1 msflex.TextMatrix(msflex.Row, 0) = msflex.rows - 1 Dim CustmrName As String CustmrName = clsobj.Retrieve_Name("select Custname from customer where custid=" & .Fields("Custid") & " ") msflex.TextMatrix(msflex.Row, 1) = CustmrName msflex.TextMatrix(msflex.Row, 2) = .Fields("InvNo") msflex.TextMatrix(msflex.Row, 3) = .Fields("InvDate") msflex.TextMatrix(msflex.Row, 4) = .Fields("TotVal") ' msflex.TextMatrix(msflex.Row, 5) = .Fields("ProdQty") Dim prsntdate As String prsntdate = Now
' If tmpTotSEEDMins >= 9999999 Then ' Call update_rec("Update License set TotSEEDtime=0") ' End If
tmpCalc = Int(tmpThisSession / 60) 'this will give no. of hours of total SEED usage 525600
If tmpCalc >= 24 Then tmpdays = Int(tmpCalc / 24) 'this will give no. of days of total SEED usage DispStr = tmpdays & " Day(s) " tmpCalc = tmpCalc Mod 24 'this will give remaining no. of hours of SEED usage (after days calculation) DispStr = DispStr & tmpCalc & " Hour(s) "
'the follg. will 'overflow' run time error 'tmpmins = tmpTotSEEDMins - ((tmpdays * 24 * 60) + (tmpCalc * 60)) 'the error is because if result crosses beyond integer value 'check this in immediate window ? 57 * 24 * 60 (where 57 is the tmpdays)
'so the resolution is with precision (instead of 60 we made 60.0 or 60#) then converting to clng tmpmins = tmpThisSession - (CLng(tmpdays * 24 * 60#) + (tmpCalc * 60)) 'if we type 60.0, compiler assumes 60#
.MoveNext Wend Else MsgBox "Details Not found..", vbCritical, mdiSSI.msgTxt End If End With clsobj.close_temp_rec
Case 2 ''''from purchase form msflex.FormatString = " Sl.No | VendorName | Inv.No. | Inv.Date. | Invoice Value | OverDueDays " '''| C-FormRefNO | C-FormAmt | ReMarks | C- FormRefDate " clsobj.open_temp_rec ("Select * from Purchase where InvNo is not null and invno<> 'Nil' and VATrCST=false and IsFormC=True order by invno") With clsobj.tmp_Rec If Not .EOF Then .MoveFirst While Not .EOF msflex.rows = msflex.rows + 1 msflex.Row = msflex.rows - 1 msflex.TextMatrix(msflex.Row, 0) = msflex.rows - 1 Dim VendName As String VendName = clsobj.Retrieve_Name("select Vendorname from Vendor where VendorCode=" & .Fields("VendorCode") & " ") msflex.TextMatrix(msflex.Row, 1) = VendName msflex.TextMatrix(msflex.Row, 2) = .Fields("InvNo") msflex.TextMatrix(msflex.Row, 3) = .Fields("InvDate") msflex.TextMatrix(msflex.Row, 4) = .Fields("TotVal") ' msflex.TextMatrix(msflex.Row, 5) = .Fields("ProdQty") Dim prsentdate As String prsentdate = Now
' If tmpTotSEEDMins >= 9999999 Then ' Call update_rec("Update License set TotSEEDtime=0") ' End If
tmpCalc = Int(tmpThisSession / 60) 'this will give no. of hours of total SEED usage 525600
If tmpCalc >= 24 Then tmpdays = Int(tmpCalc / 24) 'this will give no. of days of total SEED usage DispStr = tmpdays & " Day(s) " tmpCalc = tmpCalc Mod 24 'this will give remaining no. of hours of SEED usage (after days calculation) DispStr = DispStr & tmpCalc & " Hour(s) "
'the follg. will 'overflow' run time error 'tmpmins = tmpTotSEEDMins - ((tmpdays * 24 * 60) + (tmpCalc * 60)) 'the error is because if result crosses beyond integer value 'check this in immediate window ? 57 * 24 * 60 (where 57 is the tmpdays)
'so the resolution is with precision (instead of 60 we made 60.0 or 60#) then converting to clng tmpmins = tmpThisSession - (CLng(tmpdays * 24 * 60#) + (tmpCalc * 60)) 'if we type 60.0, compiler assumes 60#
.MoveNext Wend Else MsgBox "Details Not found..", vbCritical, mdiSSI.msgTxt End If End With clsobj.close_temp_rec
End Select
End Sub
Private Sub cmdPrint_Click() Dim clsxl As New clsExcelPrint Dim strexcelpassword As String
If msflex.rows < 2 Then MsgBox "No data to Print...", vbExclamation, mdiSSI.msgTxt Exit Sub Else On Error GoTo PRINTERRR Me.MousePointer = vbHourglass clsxl.print_preview_XL msflex, False, "C-Form Pending statement " clsxl.oexcel.Visible = True clsxl.oexcel.activeworkbook.printpreview Me.MousePointer = vbDefault End If Set clsxl = Nothing Exit Sub PRINTERRR: Me.MousePointer = vbDefault MsgBox "Printer Error !!!", vbExclamation, mdiSSI.msgTxt End Sub Private Sub load_lstFieldsValues() ' lstTopics.AddItem "MFG. & LABOUR WORK" lstFields.AddItem "MANUFACTURING" lstFields.AddItem "MFG DC CUM INVOICE" ' lstTopics.AddItem "SUB CONTRACT" lstFields.AddItem "PURCHASE" End Sub
Private Sub lstFields_Click()
If lstFields.ListIndex > 0 Then msflex.ColWidth(0) = 0 Else msflex.ColWidth(0) = 1750 End If
msflex.rows = 1 Call load_data txtEdit.Visible = False End Sub
Private Sub msflex_Click() If msflex.rows <> 1 Then
Select Case msflex.Col Case 6, 7, 8 Call placeit(msflex.Row, msflex.Col) Case Else Call placeit(msflex.Row, 6) End Select ' If msflex.Col > 5 Then ' Call placeit(msflex.Row, msflex.Col) ' Call placeit(msflex.Row, 6) ' End If End If End Sub Private Sub placeit(ByVal X As Integer, ByVal Y As Integer) Dim tmpId As Long Dim tmpUnit As Double Dim ItmId As Long msflex.Row = X msflex.Col = Y txtEdit.Move msflex.CellLeft + msflex.Left, msflex.CellTop + msflex.Top, msflex.CellWidth, msflex.CellHeight If Y = 6 Then txtEdit.MaxLength = 100 ElseIf Y = 7 Then 'if cursor got focus on 'particulars' column in msflex txtEdit.MaxLength = 100 ElseIf Y = 8 Then txtEdit.MaxLength = 100 End If txtEdit.Text = msflex.TextMatrix(X, Y) txtEdit.Visible = True txtEdit.SetFocus End Sub
Private Sub txtEdit_Change() Dim tmp As Long On Error GoTo Last msflex.TextMatrix(msflex.Row, msflex.Col) = txtEdit.Text
If msflex.Col = 7 Then msflex.TextMatrix(msflex.Row, 9) = Now End If Exit Sub Last: On Error Resume Next Call clsobj.er_hnd(Err.Description & " " & Err.Number & " " & Me.namE & "-" & Me.ActiveControl.namE, Now) End Sub
Private Sub txtEdit_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then key_used = True Select Case msflex.Col
Case 6 'column 3 index 2 'ItemCode ' If msflex.TextMatrix(msflex.Row, 6) <> "" Then msflex.Col = msflex.Col + 1 Call placeit(msflex.Row, msflex.Col) ' End If Case 7 'UOM ' If msflex.TextMatrix(msflex.Row, 2) <> "" Then msflex.Col = msflex.Col + 1 Call placeit(msflex.Row, msflex.Col) ' End If ' Case 8 'Qty '' If Val(msflex.TextMatrix(msflex.Row, 3)) <> 0 Then ' msflex.Col = msflex.Col + 1 ' Call placeit(msflex.Row, msflex.Col) '' End If Case 8 If msflex.Row < msflex.rows - 1 Then msflex.Row = msflex.Row + 1 msflex.Col = 6 Call placeit(msflex.Row, msflex.Col) Else ' If Trim(msflex.TextMatrix(msflex.Row, 1)) <> "" And Trim(msflex.TextMatrix(msflex.Row, 2)) <> "" And Val(msflex.TextMatrix(msflex.Row, 3)) <> 0 Then msflex.rows = msflex.rows + 1 'to write the slNo and move the cursor to new row Call placeit(msflex.rows - 1, 6) msflex.TextMatrix(msflex.Row, 0) = msflex.TextMatrix(msflex.Row - 1, 0) + 1 ' End If End If ' End If End Select End If End Sub Private Sub txtEdit_KeyPress(KeyAscii As Integer) If msflex.Col = 6 Or msflex.Col = 7 Then If KeyAscii > 47 And KeyAscii < 58 Or KeyAscii = 8 Or KeyAscii = 46 Then If InStr(1, txtEdit.Text, ".") > 0 And KeyAscii = 46 Then KeyAscii = 0 End If Else KeyAscii = 0 End If End If End Sub
Private Sub save_record() Dim i As Integer, cattid As Integer Dim ItemId As Long Select Case lstFields.ListIndex Case 0 'this is called from Manufacturing
For i = 1 To msflex.rows - 1 clsobj.open_temp_rec ("Select * from DcInv where InvNo is not null and invno<> 'Nil' and dcinv=False and invno= '" & msflex.TextMatrix(i, 2) & "' order by invno") With clsobj.tmp_Rec If Not .EOF Then .Fields("CformrefNo") = msflex.TextMatrix(i, 6) If msflex.TextMatrix(i, 9) = "" Then .Fields("CformRefDate") = "" Else .Fields("CformRefDate") = msflex.TextMatrix(i, 9) End If 'the ItemCode in the msflex is stored in the Item table and while displaying the record it is retrived withrespect to ItemId .Fields("CformAmt") = Val(msflex.TextMatrix(i, 7)) .Fields("CformRemarks") = msflex.TextMatrix(i, 8) If (.Fields("CformrefNo")) <> "" Or .Fields("CformAmt") > 0 Then .Fields("CformValidation") = True End If .Update End If End With clsobj.close_temp_rec Next i
Case 1 'this is called from Manufacturing dc cum invoice
For i = 1 To msflex.rows - 1 clsobj.open_temp_rec ("Select * from DcInv where InvNo is not null and invno<> 'Nil' and dcinv=True and invno= '" & msflex.TextMatrix(i, 2) & "' order by invno") With clsobj.tmp_Rec If Not .EOF Then .Fields("CformrefNo") = msflex.TextMatrix(i, 6) If msflex.TextMatrix(i, 9) = "" Then .Fields("CformRefDate") = "" Else .Fields("CformRefDate") = msflex.TextMatrix(i, 9) End If 'the ItemCode in the msflex is stored in the Item table and while displaying the record it is retrived withrespect to ItemId .Fields("CformAmt") = Val(msflex.TextMatrix(i, 7)) .Fields("CformRemarks") = msflex.TextMatrix(i, 8) If (.Fields("CformrefNo")) <> "" Or .Fields("CformAmt") > 0 Then .Fields("CformValidation") = True End If .Update End If End With clsobj.close_temp_rec Next i
Case 2 For i = 1 To msflex.rows - 1 clsobj.open_temp_rec ("Select * from Purchase where InvNo is not null and invno<> 'Nil' and invno= '" & msflex.TextMatrix(i, 2) & "' order by invno") With clsobj.tmp_Rec If Not .EOF Then .Fields("CformrefNo") = msflex.TextMatrix(i, 6) If msflex.TextMatrix(i, 9) = "" Then .Fields("CformRefDate") = "" Else .Fields("CformRefDate") = msflex.TextMatrix(i, 9) End If 'the ItemCode in the msflex is stored in the Item table and while displaying the record it is retrived withrespect to ItemId .Fields("CformAmt") = Val(msflex.TextMatrix(i, 7)) .Fields("CformRemarks") = msflex.TextMatrix(i, 8) If (.Fields("CformrefNo")) <> "" Or .Fields("CformAmt") > 0 Then .Fields("CformValidation") = True End If .Update End If End With clsobj.close_temp_rec Next i
End Select
End Sub
'********************************************************************************* ***************************** ' This file is provided as part of the Bargavi Solutions - ' ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES ' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR ' PURPOSE. ' ' Copyright (C) 2003-04 Bargavi Solutions, All rights reserved ' Purpose: Holds global Procedures and Functions for Daily Production System ' '********************************************************************************* ***************************** Public dbconnection As ADODB.Connection Public dbrec As ADODB.Recordset Public tmp_Rec As ADODB.Recordset Public tmp_Rec2 As ADODB.Recordset Public tmp_Rec3 As ADODB.Recordset Public strquery As String Dim i As Integer Public errNo As Long
'''Public whoami As String
' '********************************************************************************* ** ' Procedure: Err_Handler() ' Purpose: handles the error and write to the database. '********************************************************************************* ** Public Sub er_hnd(ByVal log As String, ByVal dt As Date) ' On Error GoTo 111: Dim err_RS As ADODB.Recordset Set err_RS = New ADODB.Recordset On Error Resume Next err_RS.Open "insert into errlog VALUES ('" & Left(log, 255) & "', #" & dt & "#)", dbconnection, adOpenDynamic, adLockOptimistic ' err_RS.Close Set err_RS = Nothing Exit Sub '111: ' 'error handler error can't do anything ' MsgBox "Unknown Error", vbCritical End Sub
'*********************** '************************************************************ ' Procedure: Get_Start() ' Purpose: Establishes connection to the database with USER SELECTED ACC.YEAR. '********************************************************************************* ** Public Sub Get_Start() Dim con_path As String On Error GoTo Report_Connection_Error Set dbconnection = New ADODB.Connection 'con_path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\DataBase\DBStart.mdb" + ";Persist Security Info=False" con_path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DataBase\DBStart.mdb" & ";Persist Security Info=False;Jet OLEDB:Database Password=Prayukti@#$SWTechPST" '& encryp_decryp("") With dbconnection .ConnectionString = con_path .Open End With Exit Sub Report_Connection_Error: MsgBox Err.Description & vbCrLf & "CAUTION: Make Sure DataBase 'DBStart.mdb' Exists in the Correct Path !!! ", vbCritical End ' to close the program if the database is not connected End Sub '********************************************************************************* ***************************** ' Procedure: Leave_DBStart ' Purpose: Releases connection to the database DBStart '********************************************************************************* ***************************** Public Sub Leave_DBstart() dbconnection.Close Set dbconnection = Nothing End Sub
'********************************************************************************* ** ' Procedure: Get_Connection() ' Purpose: Establishes connection to the database. '********************************************************************************* ** Public Sub Get_Connection() Dim con_path As String On Error GoTo Report_Connection_Error Set dbconnection = New ADODB.Connection 'con_path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path + "\DataBase\" & curr_DB_file & ";Persist Security Info=False" con_path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DataBase\" & curr_DB_file & ";Persist Security Info=False;Jet OLEDB:Database Password=Prayukti@#$SWTechPST" '& encryp_decryp("") With dbconnection .ConnectionString = con_path ' .CursorLocation = adUseClient 'MsgBox con_path .Open
End With Exit Sub Report_Connection_Error: MsgBox Err.Description & vbCrLf & "CAUTION: Make Sure DataBase Exists in the Correct Path !!! ", vbCritical End ' to close the program if the database is not connected End Sub
'********************************************************************************* ** ' Procedure: Get_Connection_mdi() ' Purpose: Establishes connection to the database, When user changes the financial year in MDI screen. '********************************************************************************* ** Public Sub Get_Connection_mdi() Dim con_path As String On Error GoTo Report_Connection_Error Set dbconnection = New ADODB.Connection curr_DB_file_mdi = "DB" & Replace(mdiSSI.cmbAccYears.Text, "-", "_") & ".mdb" 'con_path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path + "\DataBase\" & curr_DB_file & ";Persist Security Info=False" con_path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DataBase\" & curr_DB_file_mdi & ";Persist Security Info=False;Jet OLEDB:Database Password=Prayukti@#$SWTechPST" '& encryp_decryp("") With dbconnection .ConnectionString = con_path ' .CursorLocation = adUseClient 'MsgBox con_path .Open
End With Exit Sub Report_Connection_Error: MsgBox Err.Description & vbCrLf & "CAUTION: Make Sure DataBase Exists in the Correct Path !!! ", vbCritical End ' to close the program if the database is not connected End Sub
'********************************************************************************* ***************************** ' Procedure: Leave_Connection ' Purpose: Releases connection to the database '********************************************************************************* ***************************** Public Sub Leave_Connection() dbconnection.Close Set dbconnection = Nothing End Sub
'********************************************************************************* ***************************** ' Procedure: Recordset_Creation(strQuery) ' Purpose: Releases connection to the database. ' Input: strQuery containing the SQL Query to Fetch Records. '********************************************************************************* ***************************** Public Sub Recordset_Creation(strquery As String) On Error GoTo Report_Recordset_Error ' for selling purpose Set dbrec = New ADODB.Recordset With dbrec .Open strquery, dbconnection, adOpenDynamic, adLockOptimistic End With Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub '********************************************************************************* ***************************** ' Procedure: Recordset_Close() ' Purpose: Releases Recordset. '********************************************************************************* ***************************** Public Sub RecordSet_Close() On Error GoTo Report_Recordset_Error ' for selling purpose dbrec.Close Set dbrec = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub Public Function get_UnitGuide(ByVal l_ItemId As Long) As String On Error GoTo Last Dim RS_UnitGuide As ADODB.Recordset Set RS_UnitGuide = New ADODB.Recordset Call RS_UnitGuide.Open("Select * from Item where ItemId=" & l_ItemId, dbconnection, adOpenForwardOnly, adLockReadOnly) With RS_UnitGuide If Not .EOF Then ' If .Fields("measureunit") <> .Fields("ALTMeasureUnit") Then ' get_UnitGuide = "ITEM: " & .Fields("ItemCode") & " Measuring Unit (Qty) : " & .Fields("measureunit") & " <--> Alternate Unit (Alt.Qty) : " & .Fields("ALTMeasureUnit") ' Else get_UnitGuide = "ITEM: " & .Fields("ItemCode") & " UOM : " & .Fields("measureunit") '& " --> (NO Alternate Unit)"
End If End With Call RS_UnitGuide.Close Set RS_UnitGuide = Nothing 'End If Exit Function Last: MsgBox Err.Description, vbCritical End Function Public Function Retrieve_Id(ByVal querry As String) On Error GoTo Report_Recordset_Error ' for selling purpose Set dbrec_Retrieve_Ids = New ADODB.Recordset dbrec_Retrieve_Ids.Open querry, dbconnection, adOpenDynamic, adLockOptimistic With dbrec_Retrieve_Ids If Not .EOF Then If IsNull(.Fields(0)) = False Then Retrieve_Id = .Fields(0) Else Retrieve_Id = 0 End If Else Retrieve_Id = 0 End If End With dbrec_Retrieve_Ids.Close Exit Function Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Function
Public Function Retrieve_Name(ByVal querry As String) As String On Error GoTo Report_Recordset_Error ' for selling purpose Set dbrec_Retrieve_Name = New ADODB.Recordset With dbrec_Retrieve_Name .Open querry, dbconnection, adOpenDynamic, adLockOptimistic If Not .EOF Then If IsNull(.Fields(0)) = False Then Retrieve_Name = .Fields(0) Else Retrieve_Name = "" End If Else Retrieve_Name = "" End If End With dbrec_Retrieve_Name.Close Exit Function Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Function 'introduced for alt.Qty Public Function disp_Alt_Qty(ByVal l_ItemId As Long, ByVal sng_Qty_to_Conv As Single, Optional b_Conv_To_alt_UOM As Boolean = True) As Single 'PURPOSE: to calculate the alternate Qty for the given Qty or ViceVersa (two diff. units for the same ItemId) 'arguments 'l_itemId - is the itemId for which the alternate Qty to be calculated 'sng_Qty_to_Conv - is the qty for which the alt.Qty has to be calculated (Note: this sng_Qty_to_Conv may be the UOM or Alternate UOM qty -->calculation should be vice versa) 'b_Conv_To_alt_UOM -> true means calculation from Qty --> Alt.Qty 'b_Conv_To_alt_UOM -> false means calculation from Alt.Qty --> Qty
If b_Conv_To_alt_UOM = True Then 'qty to alt.Qty Calculation (given qty * unitConvert) disp_Alt_Qty = sng_Qty_to_Conv * Retrieve_Id("select UnitConvert from Item where itemid=" & l_ItemId) Else 'alt.qty to Qty Calculation (given Alt.qty * (1/unitConvert)) disp_Alt_Qty = sng_Qty_to_Conv * (1 / Retrieve_Id("select UnitConvert from Item where itemid=" & l_ItemId)) End If End Function Public Function Retrieve_TWO_Cols(ByVal querry As String) As String On Error GoTo Report_Recordset_Error ' for selling purpose Set dbrec_Retrieve_Name = New ADODB.Recordset With dbrec_Retrieve_Name .Open querry, dbconnection, adOpenDynamic, adLockOptimistic If Not .EOF Then Retrieve_TWO_Cols = .Fields(1) & " , " & .Fields(0) Else Retrieve_TWO_Cols = "" End If End With dbrec_Retrieve_Name.Close Exit Function Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Function
Public Sub open_temp_rec(ByVal querry As String) 'this can be used for insert command On Error GoTo Report_Recordset_Error ' for selling purpose Set tmp_Rec = New ADODB.Recordset With tmp_Rec .Open querry, dbconnection, adOpenDynamic, adLockOptimistic End With Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Sub close_temp_rec() On Error GoTo Report_Recordset_Error ' for selling purpose tmp_Rec.Close Set tmp_Rec = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Sub open_temp_rec2(ByVal querry As String) 'this can be used for insert command On Error GoTo Report_Recordset_Error ' for selling purpose Set tmp_Rec2 = New ADODB.Recordset With tmp_Rec2 .Open querry, dbconnection, adOpenDynamic, adLockOptimistic End With Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Sub close_temp_rec2() On Error GoTo Report_Recordset_Error ' for selling purpose tmp_Rec2.Close Set tmp_Rec2 = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Sub open_temp_rec3(ByVal querry As String) 'this can be used for insert command On Error GoTo Report_Recordset_Error ' for selling purpose Set tmp_Rec3 = New ADODB.Recordset With tmp_Rec3 .Open querry, dbconnection, adOpenDynamic, adLockOptimistic End With Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Sub close_temp_rec3() On Error GoTo Report_Recordset_Error ' for selling purpose tmp_Rec3.Close Set tmp_Rec3 = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Function chk_rec_exst(ByVal querry As String) As Boolean On Error GoTo Report_Recordset_Error ' for selling purpose Set dbrec_rec_exst = New ADODB.Recordset With dbrec_rec_exst .Open querry, dbconnection, adOpenDynamic, adLockOptimistic If Not .EOF Then chk_rec_exst = True Else chk_rec_exst = False End If End With dbrec_rec_exst.Close Exit Function Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Function Public Sub load_combo(ByRef combos As ComboBox, ByVal qryy As String) On Error GoTo Report_Recordset_Error ' for selling purpose Dim dbrec_load_data As ADODB.Recordset Set dbrec_load_data = New ADODB.Recordset combos.Clear combos.Refresh With dbrec_load_data .Open qryy, dbconnection, adOpenDynamic, adLockOptimistic If Not .EOF Then .MoveFirst While Not .EOF combos.AddItem (.Fields(1)) combos.ItemData(combos.NewIndex) = .Fields(0) .MoveNext Wend End If End With dbrec_load_data.Close Set dbrec_load_data = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub Public Sub load_combo1(ByRef combos As ComboBox, ByVal qryy As String) On Error GoTo Report_Recordset_Error ' for selling purpose Dim dbrec_load_data As ADODB.Recordset Set dbrec_load_data = New ADODB.Recordset combos.Clear combos.Refresh With dbrec_load_data .Open qryy, dbconnection, adOpenDynamic, adLockOptimistic If Not .EOF Then .MoveFirst While Not .EOF If IsNull(.Fields(0)) Then Else combos.AddItem (.Fields(0)) End If .MoveNext Wend End If End With dbrec_load_data.Close Set dbrec_load_data = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Sub load_list1(ByRef lists As ListBox, ByVal qryy As String) On Error GoTo Report_Recordset_Error ' for selling purpose Dim dbrec_load_data As ADODB.Recordset Set dbrec_load_data = New ADODB.Recordset lists.Clear lists.Refresh With dbrec_load_data .Open qryy, dbconnection, adOpenDynamic, adLockOptimistic If Not .EOF Then .MoveFirst While Not .EOF lists.AddItem (.Fields(0)) .MoveNext Wend End If End With dbrec_load_data.Close Set dbrec_load_data = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Sub load_list(ByRef lists As ListBox, ByVal qryy As String) On Error GoTo Report_Recordset_Error ' for selling purpose Dim dbrec_load_data As ADODB.Recordset Set dbrec_load_data = New ADODB.Recordset lists.Clear lists.Refresh With dbrec_load_data .Open qryy, dbconnection, adOpenDynamic, adLockOptimistic If Not .EOF Then .MoveFirst While Not .EOF lists.AddItem (.Fields(1)) lists.ItemData(lists.NewIndex) = .Fields(0) .MoveNext Wend End If End With dbrec_load_data.Close Set dbrec_load_data = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
'to get the itemdata of a listbox or combobox Public Function Get_ItemData_From_String(TmpLst As Object, tmpstr As String) As Long Dim i As Integer Get_ItemData_From_String = 0 For i = 0 To TmpLst.ListCount - 1 If UCase(tmpstr) = UCase(TmpLst.List(i)) Then Get_ItemData_From_String = TmpLst.ItemData(i) Exit For End If Next i End Function
Public Function encryp_decryp(ByVal chk As String) Dim i As Integer Dim Encrypted_Decrypted_String As String Dim ch As Byte encrypt_decrypt = chk 'Trim(txtUserPassword.Text) For i = 1 To Len(encrypt_decrypt) ch = (Asc(Mid$(encrypt_decrypt, i, 1)) + 128) Mod 256 Encrypted_Decrypted_String = Encrypted_Decrypted_String + Chr(ch) Next i encryp_decryp = Encrypted_Decrypted_String End Function
Public Function Get_Cmb_ListIndex_From_ItemData(TmpCmb As ComboBox, TmpItmData As Long) As Long Dim i As Integer Get_Cmb_ListIndex_From_ItemData = -1 For i = 0 To TmpCmb.ListCount - 1 If TmpItmData = TmpCmb.ItemData(i) Then Get_Cmb_ListIndex_From_ItemData = i Exit For End If Next i End Function
'Public Sub write_log(ByVal frmname As String, ByVal AdmNo As String) ' ' Open App.Path + "\log.txt" For Append As #1 ' If frmname = "frmStudDel" Then ' Print #1, frmname & "----> " & Now & "Admission No: " & AdmNo & " Deleted " ' Print #1, ' End If ' Close #1 'End Sub
Public Function cal_OT_Hrs(ByVal OTstr As String) As Single Dim tmpVal As String cal_OT_Hrs = 0 If Len(OTstr) = 0 Then cal_OT_Hrs = 0 Else For i = 1 To 40 'ASSUME 40 DAYS IN ACCIDENTAL DATA tmpVal = Str_Split_Using_Separator(OTstr, ",", i) If tmpVal = "" Then Exit For Else cal_OT_Hrs = cal_OT_Hrs + Val(tmpVal) End If Next i End If End Function
Public Function cal_days_Present(ByVal Lstr As String) As Single cal_days_Present = 0 If Len(Lstr) = 0 Then cal_days_Present = 0 Else For i = 1 To Len(Lstr) If Mid(Lstr, i, 1) = "P" Then cal_days_Present = cal_days_Present + 1 ElseIf Mid(Lstr, i, 1) = "N" Or Mid(Lstr, i, 1) = "M" Then cal_days_Present = cal_days_Present + 0.5 End If Next i End If End Function
Public Function cal_Leave_days(ByVal Lstr As String) As Single cal_Leave_days = 0 If Len(Lstr) = 0 Then cal_Leave_days = 0 Else For i = 1 To Len(Lstr) If Mid(Lstr, i, 1) = "L" Then cal_Leave_days = cal_Leave_days + 1 ElseIf Mid(Lstr, i, 1) = "M" Then cal_Leave_days = cal_Leave_days + 0.5 End If Next i End If End Function
Public Function cal_Holidays(ByVal HoliStr As String) As Integer 'this function will return the minus of the holidays ie working days Dim i As Integer cal_Holidays = 0 If Len(HoliStr) = 0 Then Else For i = 1 To Len(HoliStr) If Mid(HoliStr, i, 1) = "0" Then cal_Holidays = cal_Holidays + 1 End If Next i End If End Function
Public Function Str_Split_Using_Separator(ByVal Src_Str As String, ByVal sep As String, ByVal pos As Integer) As String Dim pos_cnt As Integer If pos = 0 Then MsgBox "Position Error" Exit Function End If pos_cnt = 1 While True If pos_cnt <> pos And InStr(1, Src_Str, sep) > 0 Then Src_Str = Right$(Src_Str, Len(Src_Str) - InStr(1, Src_Str, sep)) Else If InStr(1, Src_Str, sep) > 0 Then Str_Split_Using_Separator = Left$(Src_Str, InStr(1, Src_Str, sep) - 1) ElseIf InStr(1, Src_Str, sep) = 0 And pos = pos_cnt Then ' if the separator is not found fetch the remaining string Str_Split_Using_Separator = Src_Str Else Str_Split_Using_Separator = "" End If Exit Function End If pos_cnt = pos_cnt + 1 Wend End Function
'for wordWrap the given string to the given width Public Function setWidth(Expression As String, Width As Integer) As String Dim sTemp As String sTemp = vbNullString Dim arWords 'array to hold string arWords = Split(Expression, " ") Dim ipos As Integer Dim ilen As Integer ilen = 0 'From Nett ' For ipos = LBound(arWords) To UBound(arWords) 'shows the error at ubound() so Here I cutdown 1 i.e Ubound()-1 ' the above code may be used when "option base 1" 'if No option base is specified then option base is Zero by default so Ubound()-1 is used
For ipos = LBound(arWords) To UBound(arWords) ilen = ilen + Len(arWords(ipos)) sTemp = sTemp & arWords(ipos) & " " If ipos < UBound(arWords) Then If ilen + Len(arWords(ipos + 1)) > Width Then 'add a carriage return 'sTemp = sTemp & vbCrLf sTemp = sTemp & vbLf ilen = 0 End If Else If ilen + Len(arWords(ipos)) > Width Then 'add a carriage return /line feed 'sTemp = sTemp & vbCrLf sTemp = sTemp & vbLf ilen = 0 End If End If Next ipos setWidth = sTemp End Function
Public Sub update_rec(ByVal strr As String) On Error GoTo Report_Recordset_Error ' for selling purpose Dim tt_rec As ADODB.Recordset Set tt_rec = New ADODB.Recordset tt_rec.Open strr, dbconnection, adOpenDynamic, adLockOptimistic Set tt_rec = Nothing Exit Sub Report_Recordset_Error: MsgBox Err.Description, vbCritical, "e-Trans" Call er_hnd(Err.Description & " " & Err.Number & " : From ClsProd", Now) End Sub
Public Function MoneyToWords(cMoney As Long) As String Dim lRemaining As Long Dim sTempStr As String, sRtnVal As String, sSet As String Dim nNextNbr As Integer, nDigits As Integer Dim last3DigitOver As Boolean last3DigitOver = False 'lRemaining = CLng(cMoney) ' drop the cents lRemaining = CLng(cMoney) sTempStr = "000" & lRemaining nDigits = 0 'process sets of 3 digits from least to most significant Do While (IsNumeric(sTempStr) And Val(sTempStr) > 0)
'If Len(sTempStr) > 1 Then nNextNbr = Val(Right$(sTempStr, 2)) sTempStr = Left(sTempStr, Len(sTempStr) - 2) 'ElseIf Len(sTempStr) = 1 Then ' nNextNbr = Val(Right$(sTempStr, 1)) ' sTempStr = Left(sTempStr, Len(sTempStr) - 1) 'End If 'handle tens and units digits this set sSet = "" If (nNextNbr > 9 And nNextNbr < 20) Then sSet = Choose(nNextNbr - 9, "ten", "eleven", "tweleve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen") & " " & sSet ElseIf (nNextNbr > 0) Then sSet = Choose(Val(Right(Str(nNextNbr), 1)), "one", "two", "three", "four", "five", "six", "seven", "eight", "nine") & sSet End If If (nNextNbr >= 20) Then sSet = Choose(Left$(nNextNbr, 1), "error", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety") & " " & sSet End If ' the following if block code will be executed only once If last3DigitOver = False And Len(sTempStr) >= 1 Then 'handle hundreds digit in this set nNextNbr = Val(Right$(sTempStr, 1)) sTempStr = Left(sTempStr, Len(sTempStr) - 1) If (nNextNbr >= 1) Then sSet = " HUNDRED, " & sSet sSet = Choose(nNextNbr, "one", "two", "three", "four", "five", "six", "seven", "eight", "nine") & " " & sSet End If End If 'handle set suffix,no suffix if this set was "000" If (sSet <> "") Then sRtnVal = sSet & Choose(nDigits / 3, " THOUSAND, ", " LAKH, ", " CRORE, ") & sRtnVal End If If last3DigitOver = False Then last3DigitOver = True nDigits = nDigits + 3 Loop If Right(sRtnVal, 2) = ", " Then sRtnVal = Left(sRtnVal, Len(sRtnVal) - 2) End If MoneyToWords = sRtnVal End Function
Public Function cal_Actual_Holidays(ByVal HoliStr As String) As Integer 'this function will return the minus of the holidays ie working days Dim i As Integer cal_Actual_Holidays = 0 If Len(HoliStr) = 0 Then
Else For i = 1 To Len(HoliStr) If Mid(HoliStr, i, 1) = "1" Then cal_Actual_Holidays = cal_Actual_Holidays + 1 End If Next i End If
End Function
Public Function get_total_for_user_req(ByRef msflex As MSFlexGrid, ByVal r1 As Integer, ByVal r2 As Integer, ByVal c1 As Integer, ByVal c2 As Integer) Dim aa, BB aa = 0: BB = 0 If r1 > r2 Then r1 = r1 + r2 r2 = r1 - r2 r1 = r1 - r2 End If If c1 > c2 Then c1 = c1 + c2 c2 = c1 - c2 c1 = c1 - c2 End If For i = r1 To r2 For j = c1 To c2 aa = aa + Val(msflex.TextMatrix(i, j)) If Abs(c1 - c2) = 1 And j = c1 Then BB = BB + Val(msflex.TextMatrix(i, c1)) * Val(msflex.TextMatrix(i, c2)) End If Next j Next i If aa = 0 Then get_total_for_user_req = "Sum : ZERO" ElseIf BB = 0 Then get_total_for_user_req = "Sum : " & Round(aa, 2) Else get_total_for_user_req = "Sum : " & Round(aa, 2) & vbCrLf & "(C1 " & Chr(215) & " C2): " & BB End If End Function
Public Function repeat_char(ByVal ch As Integer, ByVal lengt As Integer) As String Dim tmp As String For i = 1 To lengt tmp = tmp & Chr(ch) Next i repeat_char = tmp End Function
Public Sub PSprinting(ByRef cmmDlg As CommonDialog, ByRef rtbP As RichTextBox) On Error Resume Next ' cdlPDReturnDC = 256 ' cdlPDNoPageNums = 8 ' cdlPDSelection = 1 ' cdlPDAllPages = 0
Dim f As New StdFont f.namE = "Courier New" f.Size = 11 Set Printer.Font = f
cmmDlg.Flags = cdlPDReturnDC + cdlPDNoPageNums '256 + 8 If rtbPreview.SelLength = 0 Then cmmDlg.Flags = cmmDlg.Flags + cdlPDAllPages ' + 0 Else cmmDlg.Flags = cmmDlg.Flags + cdlPDSelection End If cmmDlg.ShowPrinter rtbP.SelPrint (cmmDlg.hDC) End Sub
'+++++++++++++++++++++++++PRINTING SOLUTIONS+++++++++++++++++++++++++++++++++++++++++++ 'NOTE: IF AN EMPTY STRING STARTS WITH SPACE(n) COMMAND, SYSTEM WILL ALLOCATE 10 SPACES EXTRA WITH n required spaces, SO use 'use the code----> tmp = " " & space(69) ' (INSTEAD OF using ) ' tmp=space(70) '+++++++++++++++++++++++++PRINTING SOLUTIONS+++++++++++++++++++++++++++++++++++++++++++
Public Function LPad(ValIn As Variant, nDec As Integer, _ WidthOut As Integer) As String ' ' Formatting function left pads with spaces, using specified ' number of decimal digits. 'xstring = LPad(2.3, 2, 7) If IsNumeric(ValIn) Then If nDec > 0 Then LPad = Right$(Space$(WidthOut) & _ Format$(ValIn, "0." & String$(nDec, "0")), _ WidthOut) Else LPad = Right$(Space$(WidthOut) & Format$(ValIn, "0"), WidthOut) End If Else LPad = Right$(Space$(WidthOut) & ValIn, WidthOut) End If End Function
'Public Function get_new_dcno(ByVal currTabl As String) As Long ' 'booktype1 uses all three separate ' 'booktype2 uses mfg and lab one combined book and subcon separate book ' 'booktype3 uses all three combined in one ' Dim tmp As Long, tmp2 As Long ' Select Case mdiSSI.bookType ' Case 1 'booktype1 uses all three separate ' Select Case UCase(currTabl) ' Case "DCINV" ' If chk_rec_exst("select * from " & currTabl) Then ' tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv)"))) ' End If ' Case "DCOUTGOINGINV" ' If chk_rec_exst("select * from " & currTabl) Then ' tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv)"))) ' End If ' Case "DCSUBCONOUTGOING" ' If chk_rec_exst("select * from " & currTabl) Then ' tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcsubconOUTGOING where dcid=(select max(dcid) from dcsubconOUTGOING)"))) ' End If ' End Select ' Case 2 'booktype2 uses mfg and lab one combined book and subcon separate book ' Select Case UCase(currTabl) ' Case "DCINV" ' If chk_rec_exst("select * from dcinv") Then ' tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv)"))) ' End If ' If chk_rec_exst("select * from DCOUTGOINGINV") Then ' tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv)"))) ' End If ' If tmp2 > tmp Then tmp = tmp2 ' Case "DCOUTGOINGINV" ' If chk_rec_exst("select * from DCOUTGOINGINV") Then ' tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv)"))) ' End If ' If chk_rec_exst("select * from dcinv") Then ' tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv)"))) ' End If ' If tmp2 > tmp Then tmp = tmp2 ' Case "DCSUBCONOUTGOING" ' If chk_rec_exst("select * from dcsubconOUTGOING") Then ' tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcsubconOUTGOING where dcid=(select max(dcid) from dcsubconOUTGOING)"))) ' End If ' End Select ' Case 3 'booktype3 uses all three combined in one ' If chk_rec_exst("select * from DCINV") Then ' tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv)"))) ' End If ' If chk_rec_exst("select * from DCOUTGOINGINV") Then ' tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv)"))) ' If tmp2 > tmp Then tmp = tmp2 ' End If ' If chk_rec_exst("select * from DCSUBCONOUTGOING") Then ' tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcsubconOUTGOING where dcid=(select max(dcid) from dcsubconOUTGOING)"))) ' If tmp2 > tmp Then tmp = tmp2 ' End If ' End Select ' 'In the previous codes we obtain the maximum DCNO if it is not alphanumeric, suppose it is numeric only ' 'ALSO since the duplication is checked with every DC say mfg,labour,subcontract (all Outgoing DCs) ' 'No need to check the duplication of obtained maximum DCNO ' 'If conditions are changed by the end user then we should add the ' 'code for checking the found out DCNO + 1 in any of the DCs ' ' get_new_dcno = tmp + 1 ' 'End Function ' 'Public Function get_new_Invoiceno(ByVal currTabl As String) As Long ' 'booktype1 uses all three separate ' 'booktype2 uses mfg and lab one combined book and subcon separate book ' 'booktype3 uses all three combined in one ' ' Dim tmp As Long, tmp2 As Long ' Select Case mdiSSI.bookTypeINV ' Case 2 'booktype2 uses 2 type of books for mfg and labour ' Select Case UCase(currTabl) ' Case "DCINV" ' If chk_rec_exst("select * from DCINV") Then ' tmp = CLng(Val(Retrieve_Name("SELECT invno from dcinv where invdatet=(select max(invdatet) from dcinv where invno is not null and InvNo<>'Nil')"))) ' End If ' Case "DCOUTGOINGINV" ' If chk_rec_exst("select * from DCOUTGOINGINV") Then ' tmp = CLng(Val(Retrieve_Name("SELECT invno from dcOUTGOINGinv where invdatet=(select max(invdatet) from dcoutgoinginv where invno is not null and InvNo<>'Nil')"))) ' End If ' End Select ' Case 1 'booktype1 uses one book for both type of invoices ' 'booktype3 uses all three combined in one ' If chk_rec_exst("select * from DCINV") Then ' tmp = CLng(Val(Retrieve_Name("SELECT invno from dcinv where invdatet=(select max(invdatet) from dcinv where invno is not null and InvNo<>'Nil')"))) ' End If ' If chk_rec_exst("select * from DCOUTGOINGINV") Then ' tmp2 = CLng(Val(Retrieve_Name("SELECT invno from dcOUTGOINGinv where invdatet=(select max(invdatet) from dcoutgoinginv where invno is not null and InvNo<>'Nil')"))) ' If tmp2 > tmp Then tmp = tmp2 ' End If ' End Select ' get_new_Invoiceno = tmp + 1 'End Function
'DONE FOR AUTO NO For EVERY YEAR (full block Changed) Public Function get_new_dcno(ByVal currTabl As String) As Long 'booktype1 uses all three separate 'booktype2 uses mfg and lab one combined book and subcon separate book 'booktype3 uses all three combined in one Dim tmp As Long, tmp2 As Long Select Case mdiSSI.bookType Case 1 'booktype1 uses all three separate Select Case UCase(currTabl) Case "DCINV" If chk_rec_exst("select * from " & currTabl) Then 'tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv where dcdateT between #4/1/" & Mid(curr_DB_file, 3, 4) & "# and #3/31/" & Val(Mid(curr_DB_file, 3, 4)) + 1 & " 23:59#)"))) tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv where dcinv = False and dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If Case "DCOUTGOINGINV" If chk_rec_exst("select * from " & currTabl) Then tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If Case "DCSUBCONOUTGOING" If chk_rec_exst("select * from " & currTabl) Then tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcsubconOUTGOING where dcid=(select max(dcid) from dcsubconOUTGOING where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If End Select Case 2 'booktype2 uses mfg and lab one combined book and subcon separate book Select Case UCase(currTabl) Case "DCINV" If chk_rec_exst("select * from dcinv") Then tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If If chk_rec_exst("select * from DCOUTGOINGINV") Then tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If If tmp2 > tmp Then tmp = tmp2 Case "DCOUTGOINGINV" If chk_rec_exst("select * from DCOUTGOINGINV") Then tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If If chk_rec_exst("select * from dcinv") Then tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If If tmp2 > tmp Then tmp = tmp2 Case "DCSUBCONOUTGOING" If chk_rec_exst("select * from dcsubconOUTGOING") Then tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcsubconOUTGOING where dcid=(select max(dcid) from dcsubconOUTGOING where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If End Select Case 3 'booktype3 uses all three combined in one If chk_rec_exst("select * from DCINV") Then tmp = CLng(Val(Retrieve_Name("SELECT dcno from dcinv where dcinvid=(select max(dcinvid) from dcinv where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If If chk_rec_exst("select * from DCOUTGOINGINV") Then tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcOUTGOINGinv where dcid=(select max(dcid) from dcoutgoinginv where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) If tmp2 > tmp Then tmp = tmp2 End If If chk_rec_exst("select * from DCSUBCONOUTGOING") Then tmp2 = CLng(Val(Retrieve_Name("SELECT dcno from dcsubconOUTGOING where dcid=(select max(dcid) from dcsubconOUTGOING where dcdateT between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) If tmp2 > tmp Then tmp = tmp2 End If End Select 'In the previous codes we obtain the maximum DCNO if it is not alphanumeric, suppose it is numeric only 'ALSO since the duplication is checked with every DC say mfg,labour,subcontract (all Outgoing DCs) 'No need to check the duplication of obtained maximum DCNO 'If conditions are changed by the end user then we should add the 'code for checking the found out DCNO + 1 in any of the DCs
get_new_dcno = tmp + 1
'if the value is 1 , then we are alerting the end user, that he/she is in the next financial year 'curr_DB_file will hold the string db2007_08 i.e the database name from which we capture the financial year(starting year) and comparing with get_FinYear(date) ===> if curr fin. database not found then caution(message box) will expand with iif condition (true condition) otherwise no extra message If Val(get_new_dcno) = 1 Then MsgBox "You are about to start New Records for this FINANCIAL YEAR " & get_FinYear(Date) & "-" & (get_FinYear(Date) + 1) & _ vbCrLf & vbCrLf & vbCrLf & IIf(Mid(curr_DB_file, 3, 4) <> get_FinYear(Date), "!!! STOP PROCEEDING FURTHER --- Please Read the Following !!! " & _ vbCrLf & vbCrLf & " We recommend you to close this software and Proceed with 'MaintainFinYear.Exe' Software Kit supplied along with this e-Trans Software", ""), _ vbInformation, "e-Trans SOFTWARE - ALERT" End If
End Function
'DONE FOR AUTO NO For EVERY YEAR (full block Changed) Public Function get_new_Invoiceno(ByVal currTabl As String) As Long 'booktype1 uses all three separate 'booktype2 uses mfg and lab one combined book and subcon separate book 'booktype3 uses all three combined in one
Dim tmp As Long, tmp2 As Long Select Case mdiSSI.bookTypeINV Case 2 'booktype2 uses 2 type of books for mfg and labour Select Case UCase(currTabl) Case "DCINV" If chk_rec_exst("select * from DCINV") Then tmp = CLng(Val(Retrieve_Name("SELECT invno from dcinv where invdatet=(select max(invdatet) from dcinv where invno is not null and InvNo<>'Nil' and invdatet between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If Case "DCOUTGOINGINV" If chk_rec_exst("select * from DCOUTGOINGINV") Then tmp = CLng(Val(Retrieve_Name("SELECT invno from dcOUTGOINGinv where invdatet=(select max(invdatet) from dcoutgoinginv where invno is not null and InvNo<>'Nil' and invdatet between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If End Select Case 1 'booktype1 uses one book for both type of invoices 'booktype3 uses all three combined in one If chk_rec_exst("select * from DCINV") Then tmp = CLng(Val(Retrieve_Name("SELECT invno from dcinv where invdatet=(select max(invdatet) from dcinv where invno is not null and InvNo<>'Nil' and IsProforma<>True and invdatet between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) End If If chk_rec_exst("select * from DCOUTGOINGINV") Then tmp2 = CLng(Val(Retrieve_Name("SELECT invno from dcOUTGOINGinv where invdatet=(select max(invdatet) from dcoutgoinginv where invno is not null and InvNo<>'Nil' and invdatet between #4/1/" & get_FinYear(Date) & "# and #3/31/" & get_FinYear(Date) + 1 & " 23:59#)"))) If tmp2 > tmp Then tmp = tmp2 End If End Select get_new_Invoiceno = tmp + 1
'if the value is 1 , then we are alerting the end user, that he/she is in the next financial year 'curr_DB_file will hold the string db2007_08 i.e the database name from which we capture the financial year(starting year) and comparing with get_FinYear(date) ===> if curr fin. database not found then caution(message box) will expand with iif condition (true condition) otherwise no extra message If Val(get_new_Invoiceno) = 1 Then MsgBox "You are about to start New Records for this FINANCIAL YEAR " & get_FinYear(Date) & "-" & (get_FinYear(Date) + 1) & _ vbCrLf & vbCrLf & vbCrLf & IIf(Mid(curr_DB_file, 3, 4) <> get_FinYear(Date), "!!! STOP PROCEEDING FURTHER --- Please Read the Following !!! " & _ vbCrLf & vbCrLf & " We recommend you to close this software and Proceed with 'MaintainFinYear.Exe' Software Kit supplied along with this e-Trans Software", ""), _ vbInformation, "e-Trans SOFTWARE - ALERT" End If
End Function
Public Function IsAvailPO(ByVal custid As Long, ByVal strPO As String, ByVal tbl As String) As Boolean If UCase(tbl) = "SUBCONPO" Then If chk_rec_exst("select * from " & tbl & " where suPPid=" & custid & " and PONo='" & ReplStr(strPO, "'", "''") & "'") = True Then IsAvailPO = True Else IsAvailPO = False End If Else If chk_rec_exst("select * from " & tbl & " where CUstid=" & custid & " and PONo='" & ReplStr(strPO, "'", "''") & "'") = True Then IsAvailPO = True Else IsAvailPO = False End If End If End Function
Public Function IsAvailPO_subcon(ByVal suppid As Long, ByVal strPO As String, ByVal tbl As String) As Boolean If chk_rec_exst("select * from " & tbl & " where suppid=" & suppid & " and PONo='" & ReplStr(strPO, "'", "''") & "'") = True Then IsAvailPO_subcon = True Else IsAvailPO_subcon = False End If End Function ' '--------------------------------------------------------------------- '""""""""""""""""""""""""""ERROR HANDLING""""""""""""""""""""""""""""" '---------------------------------------------------------------------
Public Function err_display(ByVal errNo As Long) As String 'Case "-2147217900(80040e14)" If errNo = -2.1472179008004E+28 Then err_display = "Syntax error" ElseIf errNo = 5 Then err_display = "Invalid Procedure Call" 'Case "2147217887(80040e21)" ElseIf errNo = 2.1472178878004E+35 Then err_display = "Field is too small to accept the data you typed" 'Case "-214747887(80040e21)" ElseIf errNo = -2.147478878004E+34 Then err_display = "The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at same time" Else err_display = "Read - Write Error" End If
End Function
Public Function msf_check_valid_itm(ByRef msfT As MSFlexGrid, ByVal co As Integer) As Boolean Dim i As Integer, j As Integer msf_check_valid_itm = False For i = 1 To msfT.rows - 2 For j = i + 1 To msfT.rows - 1 If Trim(msfT.TextMatrix(i, co)) = Trim(msfT.TextMatrix(j, co)) Then MsgBox "Duplication of Part No./ Items is not allowed. SEE ROWS: " & i & " and " & j, vbCritical Exit Function End If Next j Next i msf_check_valid_itm = True End Function
Public Function msf_RowQty_OK_if_red(ByRef msfT As MSFlexGrid, ByVal Co1 As Integer, ByVal co2 As Integer) As Boolean 'this function is used to check for the rows which are in Yellow data i.e POBALqty in msflex, to check with user typed 'Qty' with 'POBalQty' (only if POBALqty is yellow it will be checked with Qty) Dim i As Integer msf_RowQty_OK_if_red = True With msfT .Col = co2 For i = 1 To .rows - 1 .Row = i If .CellForeColor = vbRed Then 'if yellow color If Val(.TextMatrix(i, Co1)) > Val(.TextMatrix(i, co2)) Then MsgBox "In Row: " & i & " , Qty should not be greater than " & Val(.TextMatrix(i, co2)), vbCritical, mdiSSI.msgTxt msf_RowQty_OK_if_red = False Exit Function End If End If Next i End With End Function
Public Function msf_RowQty_OK_with_StockPO(ByRef msfT As MSFlexGrid, ByVal Co1 As Integer, ByVal co2 As Integer) As Boolean 'this function is used to check for all the rows in msflex, with user typed 'Qty' with 'StkQty' or 'POBalQty' based on the request. Dim i As Integer msf_RowQty_OK_with_StockPO = True With msfT For i = 1 To .rows - 1 If Val(.TextMatrix(i, Co1)) > Val(.TextMatrix(i, co2)) Then MsgBox "In Row: " & i & " , Qty should not be greater than " & Val(.TextMatrix(i, co2)), vbCritical, mdiSSI.msgTxt msf_RowQty_OK_with_StockPO = False Exit Function End If Next i End With End Function
Public Function remove_all_vbcrlf(ByVal strCRLF As String) As String 'to remove unwanted vbcrlf in a string (Generally at the END of the string) While Right(strCRLF, 1) = vbCr Or Right(strCRLF, 1) = vbLf strCRLF = Left(strCRLF, Len(strCRLF) - 1) Wend remove_all_vbcrlf = strCRLF End Function
Public Function ReplStr(sSrcStr As String, sFind As String, sReplaceWith As String) As String Dim nStart As Long, sStr As String, nStrLen As Long
nStart = 1 nStrLen = Len(sReplaceWith) While nStart <> 0 nStart = InStr(nStart, sSrcStr, sFind) If nStart > 0 Then sSrcStr = Left(sSrcStr, nStart - 1) & sReplaceWith & Mid(sSrcStr, nStart + Len(sFind)) nStart = nStart + nStrLen End If Wend ReplStr = sSrcStr
End Function
Public Sub show_help(ByVal f_path As String) Dim i As Long On Error GoTo Last i = Shell(App.Path & "\Help\hh.exe" & " " & App.Path & "\Help\" & f_path, vbMaximizedFocus) Exit Sub Last: MsgBox "Help files are not installed!!!", vbInformation, mdiSSI.msgTxt End Sub
' ' Public Function Replace(sIn As String, sFind As String, _ ' sReplace As String, Optional nStart As Long = 1, _ ' Optional nCount As Long = -1, Optional bCompare As _ ' VbCompareMethod = vbBinaryCompare) As String ' ' Dim nC As Long, nPos As Integer, sOut As String ' sOut = sIn ' nPos = InStr(nStart, sOut, sFind, bCompare) ' If nPos = 0 Then GoTo EndFn: ' Do ' nC = nC + 1 ' sOut = Left(sOut, nPos - 1) & sReplace & _ ' Mid(sOut, nPos + Len(sFind)) ' If nCount <> -1 And nC >= nCount Then Exit Do ' nPos = InStr(nStart, sOut, sFind, bCompare) ' Loop While nPos > 0 'EndFn: ' Replace = sOut 'End Function
'Function Description() '-------- ----------- 'Join Used to join arrays elements. ' 'Split Split a string into a variant array. ' 'InStrRev Similar to InStr but searches from end of string. ' 'Replace To find a particular string and replace it. ' 'Reverse To reverse a string. ' 'If these functions are coded and added in a module, 'all the above functions can be used in the project as if they are intrinsic functions. ' ' ' ' Public Function Join(source() As String, Optional _ ' sDelim As String = " ") As String ' Dim sOut As String, iC As Integer ' On Error GoTo errh: ' For iC = LBound(source) To UBound(source) - 1 ' sOut = sOut & source(iC) & sDelim ' Next ' sOut = sOut & source(iC) ' Join = sOut ' Exit Function 'errh: ' Err.Raise Err.Number ' End Function ' ' Public Function Split(ByVal sIn As String, Optional sDelim As _ ' String, Optional nLimit As Long = -1, Optional bCompare As _ ' VbCompareMethod = vbBinaryCompare) As Variant ' Dim sRead As String, sOut() As String, nC As Integer ' If sDelim = "" Then ' Split = sIn ' End If ' sRead = ReadUntil(sIn, sDelim, bCompare) ' Do ' ReDim Preserve sOut(nC) ' sOut(nC) = sRead ' nC = nC + 1 ' If nLimit <> -1 And nC >= nLimit Then Exit Do ' sRead = ReadUntil(sIn, sDelim) ' Loop While sRead <> "" ' ReDim Preserve sOut(nC) ' sOut(nC) = sIn ' Split = sOut ' End Function ' ' Public Function ReadUntil(ByRef sIn As String, _ ' sDelim As String, Optional bCompare As VbCompareMethod _ ' = vbBinaryCompare) As String ' Dim nPos As String ' nPos = InStr(1, sIn, sDelim, bCompare) ' If nPos > 0 Then ' ReadUntil = Left(sIn, nPos - 1) ' sIn = Mid(sIn, nPos + Len(sDelim)) ' End If ' End Function ' ' Public Function StrReverse(ByVal sIn As String) As String ' Dim nC As Integer, sOut As String ' For nC = Len(sIn) To 1 Step -1 ' sOut = sOut & Mid(sIn, nC, 1) ' Next ' StrReverse = sOut ' End Function ' ' Public Function InStrRev(ByVal sIn As String, sFind As String, _ ' Optional nStart As Long = 1, Optional bCompare As _ ' VbCompareMethod = vbBinaryCompare) As Long ' Dim nPos As Long ' sIn = StrReverse(sIn) ' sFind = StrReverse(sFind) ' nPos = InStr(nStart, sIn, sFind, bCompare) ' If nPos = 0 Then ' InStrRev = 0 ' Else ' InStrRev = Len(sIn) - nPos - Len(sFind) + 2 ' End If ' End Function '
'******************************** 'MULTI USERS IN NETWORK 'New Functions onwards 19-03-2006 ' '******************************** Public Sub Register_User_Log(ByVal TmpScrId As String, Optional ByVal TmpUsrVal As Long = 1) 'Id 'Auto Number 'DateT SysId UserId 'ScreenId 'This allow u those have the user right greater than read rights
On Error GoTo Register_User_Log_Error '********************************************************************************* ************* 'Here Previously it was not insert the record where uservalue < 3 '================================================================================= ============= '''''''''''''''''''''''''''''''''' If TmpUsrVal > 1 Then '''''''''''''''''''''''''''''''''' Dim db_reg_User As ADODB.Recordset '''''''''''''''''''''''''''''''''' Set db_reg_User = New ADODB.Recordset '''''''''''''''''''''''''''''''''' Call db_reg_User.Open("Select * from OnLineUsers", dbconnection, adOpenDynamic, adLockOptimistic) '''''''''''''''''''''''''''''''''' With db_reg_User '''''''''''''''''''''''''''''''''' .AddNew '''''''''''''''''''''''''''''''''' .Fields("DateT") = Now '''''''''''''''''''''''''''''''''' .Fields("SysId") = SYS_ID '''''''''''''''''''''''''''''''''' .Fields("UserId") = whoami '''''''''''''''''''''''''''''''''' .Fields("UserVal") = TmpUsrVal '''''''''''''''''''''''''''''''''' .Fields("ScreenId") = TmpScrId '''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''' '**************************************** '''''''''''''''''''''''''''''''''' ' Old Fields Removed from the table '''''''''''''''''''''''''''''''''' ' .Fields("IsRunning") = True '''''''''''''''''''''''''''''''''' ' .Fields("RecId") = TmpRecId '''''''''''''''''''''''''''''''''' ' .Fields("ActionId") = TmpActId '''''''''''''''''''''''''''''''''' '**************************************** '''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''' .Update '''''''''''''''''''''''''''''''''' End With '''''''''''''''''''''''''''''''''' Call db_reg_User.Close '''''''''''''''''''''''''''''''''' Set db_reg_User = Nothing '''''''''''''''''''''''''''''''''' End If '================================================================================= ========
Dim db_reg_User As ADODB.Recordset Set db_reg_User = New ADODB.Recordset Call db_reg_User.Open("Select * from OnLineUsers", dbconnection, adOpenDynamic, adLockOptimistic) With db_reg_User .AddNew .Fields("DateT") = Now .Fields("SysId") = SYS_ID .Fields("UserId") = whoami .Fields("UserVal") = TmpUsrVal .Fields("ScreenId") = TmpScrId
'**************************************** ' Old Fields Removed from the table ' .Fields("IsRunning") = True ' .Fields("RecId") = TmpRecId ' .Fields("ActionId") = TmpActId '****************************************
.Update End With Call db_reg_User.Close Set db_reg_User = Nothing Exit Sub Register_User_Log_Error: MsgBox Err.Description, vbCritical End Sub Public Sub UnRegister_User_Log(ByVal TmpScrId As String) On Error GoTo UnRegister_User_Log_Error Call update_rec("delete * from OnLineUsers Where SysId=" & SYS_ID & " and UserId=" & whoami & " and ScreenId='" & Replace(TmpScrId, "'", "''") & "'") Exit Sub ' Dim db_unReg_User As ADODB.Recordset ' Set db_unReg_User = New ADODB.Recordset ' 'Call db_unReg_User.Open("Select * from OnLineUsers Where DateT Between #" & Format(Now, "mm/dd/yyyy") & "# and #" & Format(Now, "mm/dd/yyyy") & " 23:59 # and SysId=" & SYS_ID & " and UserId=" & whoami & " and ScreenId='" & replace(TmpScrId,"'","''") & "'", dbconnection, adOpenDynamic, adLockOptimistic) ' Call db_unReg_User.Open("Select * from OnLineUsers Where DateT Between #" & Format(Now, "mm/dd/yyyy") & "# and #" & Format(Now, "mm/dd/yyyy") & " 23:59 # and SysId=" & SYS_ID & " and UserId=" & whoami & " and ScreenId='" & replace(TmpScrId,"'","''") & "'", dbconnection, adOpenDynamic, adLockOptimistic) ' With db_unReg_User ' If Not .EOF Then ' .Delete (adAffectCurrent) ' End If ' End With ' Call db_unReg_User.Close ' Set db_unReg_User = Nothing ' Exit Sub UnRegister_User_Log_Error: MsgBox Err.Description, vbCritical End Sub Public Sub Clear_Scr_Log_For_SysId() 'This one clear all logs for that particular system id while open or Close the application On Error GoTo Clear_Scr_Log_For_SysId_Error Call update_rec("delete * from OnLineUsers Where SysId=" & SYS_ID) Exit Sub
' Dim db_unReg_SysId As ADODB.Recordset ' Set db_unReg_SysId = New ADODB.Recordset ' 'Call db_unReg_SysId.Open("Select * from OnLineUsers Where DateT Between #" & Format(Now, "mm/dd/yyyy") & "# and #" & Format(Now, "mm/dd/yyyy") & " 23:59 # and SysId=" & SYS_ID & " and UserId=" & whoami & " and ScreenId='" & replace(TmpScrId,"'","''") & "'", dbconnection, adOpenDynamic, adLockOptimistic) ' Call db_unReg_SysId.Open("Select * from OnLineUsers Where SysId=" & SYS_ID, dbconnection, adOpenDynamic, adLockOptimistic) ' With db_unReg_SysId ' If Not .EOF Then ' .Delete (adAffectCurrent) ' End If ' End With ' Call db_unReg_SysId.Close ' Set db_unReg_SysId = Nothing
Clear_Scr_Log_For_SysId_Error: MsgBox Err.Description, vbCritical End Sub Public Function Chk_More_Users_In_Screen(ByVal ScrId As String) As Boolean '********************************************************** 'This Function is used for check the current screen, 'Is there more users working in it 'before the save or modify or delete the record '**********************************************************
'********************************************************** 'It receives the OnlineUsers.DateT and 'Check with the Other Users in same screen By OnlineUsers.DateT(Where SysId<>Current SysId) 'The DateT is Greater than or Equal to others, It will show the error message and control back to called place '********************************************************** Dim TmpDateT As String
Chk_More_Users_In_Screen = True TmpDateT = Retrieve_Name("Select DateT from OnLineUsers Where ScreenId='" & Replace(ScrId, "'", "''") & "' and SysId=" & SYS_ID & " and UserId=" & whoami)
'If data reterival causes will happen If Trim(TmpDateT) = "" Then MsgBox "Your Log was deleted by the Administrator.Contact Ur Administrator", vbCritical, mdiSSI.msgTxt Chk_More_Users_In_Screen = False 'Exit Function End If
Call open_temp_rec("Select * from OnLineUsers Where UserVal>1 and ScreenId='" & Replace(ScrId, "'", "''") & "' and SysId <>" & SYS_ID) With tmp_Rec If Not .EOF Then While Not .EOF And Chk_More_Users_In_Screen 'Here We check my Date and Time is Greater than Equal to Some other User If Format(TmpDateT, "DD/mm/yyyy HH:MM:SS") >= Format(.Fields("DateT"), "DD/mm/yyyy HH:MM:SS") Then MsgBox "This Screen was already opened by " & vbLf & "User Name : " & Retrieve_Name("Select UserName from User1 Where UserId=" & .Fields("UserId")) & vbLf & "System Name : " & Retrieve_Name("Select SysName from ImpSystems Where SysId=" & .Fields("SysId")) & vbLf & "Date / Time : " & .Fields("DateT") & vbLf & "Ur Screen Log Date / Time : " & TmpDateT, vbCritical, mdiSSI.msgTxt Chk_More_Users_In_Screen = False End If .MoveNext Wend End If End With Call close_temp_rec Exit Function Chk_More_Users_In_Screen_Error: MsgBox Err.Description End Function Public Function Fix_userVal_ReadOnly_if_screen_already_exist(ByVal ScrId As String, ByVal tmpUserVal As Long) As Long '==================================================================== ' USAGE: ' in Multi-user Session, if two users are having save/Modify/Delete ' rights, and if two users trying to use the same screen, the second ' user's user_value(refer the userRights value) will be set to One ' i.e Read-only '==================================================================== On Error GoTo Fix_userVal_ReadOnly_if_screen_already_exist_Err_Handler Fix_userVal_ReadOnly_if_screen_already_exist = tmpUserVal Call open_temp_rec("Select * from OnlineUsers Where UserVal>1 and SysId<>" & SYS_ID & " and ScreenId='" & Replace(ScrId, "'", "''") & "' Order By DateT") With tmp_Rec If Not .EOF Then MsgBox "This Screen was already opened by" & vbLf & "User Name : " & Retrieve_Name("Select UserName from User1 Where UserId=" & .Fields("UserId")) & vbLf & "System Name : " & Retrieve_Name("Select SysName from ImpSystems Where SysId=" & .Fields("SysId")) & vbLf & "Date / Time : " & .Fields("DateT") & vbLf & "So U can't Save or Modify or Delete any record", vbCritical, mdiSSI.msgTxt Fix_userVal_ReadOnly_if_screen_already_exist = 1 End If End With Call close_temp_rec Exit Function Fix_userVal_ReadOnly_if_screen_already_exist_Err_Handler: Exit Function End Function 'to get the item listindex using a itemdata value Public Function Get_ListIndex_From_ItemData(TmpLst As Object, TmpItmData As Long) As Long Dim i As Integer Get_ListIndex_From_ItemData = -1 For i = 0 To TmpLst.ListCount - 1 If TmpItmData = TmpLst.ItemData(i) Then Get_ListIndex_From_ItemData = i Exit For End If Next i End Function Public Function Get_cmbRlist_ListIndex(ByRef CmbRListbox As Object, ByVal tmpId As Long) As Long Dim l As Long l = -1 Get_cmbRlist_ListIndex = -1 For l = 0 To CmbRListbox.ListCount - 1 If tmpId = CmbRListbox.ItemData(l) Then Get_cmbRlist_ListIndex = l Exit Function End If Next l End Function
Public Function Remove_setBrackets_N_duplicates(ByVal SrcStr As String) As String Dim i As Integer, curr_DC_R_PO As String Dim finalStr As String Dim tmpstr As String Dim TmpPlace, EndPlace As Integer If InStr(SrcStr, ",") > 0 Then For i = 1 To 200 curr_DC_R_PO = Str_Split_Using_Separator(SrcStr, ",", i) If curr_DC_R_PO = "" Then Exit For Else If finalStr <> "" Or curr_DC_R_PO <> "" Then If InStr(1, finalStr, curr_DC_R_PO & ",") > 0 Or InStr(1, finalStr, "," & curr_DC_R_PO & ",") > 0 Or InStr(1, finalStr, "," & curr_DC_R_PO) > 0 Then 'do nothing Else TmpPlace = InStr(1, curr_DC_R_PO, "{") If TmpPlace > 0 Then finalStr = finalStr & Left(curr_DC_R_PO, TmpPlace - 1) & "," Else finalStr = finalStr & (curr_DC_R_PO) & "," End If End If Else finalStr = (curr_DC_R_PO) & "," End If End If Next i Remove_setBrackets_N_duplicates = Left(finalStr, Len(finalStr) - 1) Else TmpPlace = InStr(1, SrcStr, "{") If TmpPlace > 0 Then Remove_setBrackets_N_duplicates = Left(SrcStr, TmpPlace - 1) Else Remove_setBrackets_N_duplicates = (SrcStr) End If End If End Function
Public Function Count_File_Corres(ParentScr As String, FileKey As String, NameId As Long) As Long '''''''On Error GoTo Report_Recordset_Error ' for selling purpose
Dim CrtStr As String Dim TmpQry As String Dim strqry As String
If FILE_CORR_ENABLE Then FileKey = Trim(FileKey)
CrtStr = ""
If (FileKey) <> "" And NameId <> 0 Then CrtStr = " and FileKey='" & Replace(FileKey, "'", "''") & "' and NameId=" & NameId ElseIf (FileKey) <> "" Then CrtStr = " and FileKey='" & Replace(FileKey, "'", "''") & "'" ElseIf NameId <> 0 Then CrtStr = " and NameId=" & NameId End If
Select Case UCase(ParentScr) Case UCase("frmCustomer") strqry = "select Count(*) from FileCorres Where FileCat='Customers'" Case UCase("frmServiceCustomer") strqry = "select Count(*) from FileCorres Where FileCat='ServiceCustomers'" Case UCase("frmSupplier") strqry = "select Count(*) from FileCorres Where FileCat='Suppliers'" Case UCase("frmVendor") strqry = "select Count(*) from FileCorres Where FileCat='Vendors'" Case UCase("frmStaff") strqry = "select Count(*) from FileCorres Where FileCat='Staffs'" Case UCase("frmItem") strqry = "select Count(*) from FileCorres Where FileCat='Items'" Case UCase("frmServiceItem") strqry = "select Count(*) from FileCorres Where FileCat='ServiceItems'" Case UCase("frmEstimation") strqry = "select Count(*) from FileCorres Where FileCat='Estimation'" Case UCase("frmPurchasePO") strqry = "select Count(*) from FileCorres Where FileCat='Purchase PO'" Case UCase("frmPurchase") strqry = "select Count(*) from FileCorres Where FileCat='Purchase'" Case UCase("frmPurchaseGRN") strqry = "select Count(*) from FileCorres Where FileCat='Purchase GRN'" Case UCase("frmInvoicePurch") strqry = "select Count(*) from FileCorres Where FileCat='Purchase Invoice'" Case UCase("frmQuote") strqry = "select Count(*) from FileCorres Where FileCat='Quotation'" Case UCase("frmMfgPO") strqry = "select Count(*) from FileCorres Where FileCat='Mfg Po'" Case UCase("frmdc") strqry = "select Count(*) from FileCorres Where FileCat='Mfg DC'" Case UCase("frmDcInvoice") strqry = "select Count(*) from FileCorres Where FileCat='Mfg DCInvoice'" Case UCase("frmInvoice") strqry = "select Count(*) from FileCorres Where FileCat='Mfg Invoice'" Case UCase("frmLabourPO") strqry = "select Count(*) from FileCorres Where FileCat='Labour Po'" Case UCase("frmDCIncoming") strqry = "select Count(*) from FileCorres Where FileCat='Labour DC Inwards'" Case UCase("frmDCOutgoing") strqry = "select Count(*) from FileCorres Where FileCat='Labour DC Outwards'" Case UCase("frmInvoiceL") strqry = "select Count(*) from FileCorres Where FileCat='Labour Invoice'" Case UCase("frmSubConPO") strqry = "select Count(*) from FileCorres Where FileCat='SubContract PO'" Case UCase("frmDCSubConOut") strqry = "select Count(*) from FileCorres Where FileCat='SubContract DC Outwards'" Case UCase("frmDCSubConIn") strqry = "select Count(*) from FileCorres Where FileCat='SubContract DC Inwards'" Case UCase("frmInvoiceSC") strqry = "select Count(*) from FileCorres Where FileCat='SubContract Invoice'" Case UCase("frmPayments") strqry = "select Count(*) from FileCorres Where FileCat='Payments'" Case UCase("frmReceipts") strqry = "select Count(*) from FileCorres Where FileCat='Receipts'" Case UCase("frmBankTrans") strqry = "select Count(*) from FileCorres Where FileCat='Bank Transactions'" Case UCase("frmAdvAdjust") strqry = "select Count(*) from FileCorres Where FileCat='Adjustments'" Case UCase("frmInspection") strqry = "select Count(*) from FileCorres Where FileCat='Random Inspection'" Case UCase("frmInspectionInde") strqry = "select Count(*) from FileCorres Where FileCat='Individual Inspection'" Case UCase("frmInspectionSC") strqry = "select Count(*) from FileCorres Where FileCat='SubContract Inspection'" Case UCase("frmInspectionIn") strqry = "select Count(*) from FileCorres Where FileCat='Common Inspection'" Case UCase("frmMisc") strqry = "select Count(*) from FileCorres Where FileCat='Company Details'" End Select
Count_File_Corres = 0
TmpQry = strqry & CrtStr
If TmpQry <> "" Then Count_File_Corres = Retrieve_Id(TmpQry) End If Else Count_File_Corres = 0 End If End Function
Public Function get_SEED_total_usage_in_words() As String Dim tmpTotSEEDMins As Long Dim tmpdays As Long Dim tmphrs As Long Dim tmpmins As Long Dim tmpCalc As Long Dim DispStr As String
tmpTotSEEDMins = Retrieve_Id("select TotSEEDtime from License") If tmpTotSEEDMins >= 9999999 Then Call update_rec("Update License set TotSEEDtime=0") End If tmpCalc = Int(tmpTotSEEDMins / 60) 'this will give no. of hours of total SEED usage If tmpCalc >= 24 Then tmpdays = Int(tmpCalc / 24) 'this will give no. of days of total SEED usage DispStr = tmpdays & " Day(s) " tmpCalc = tmpCalc Mod 24 'this will give remaining no. of hours of SEED usage (after days calculation) DispStr = DispStr & tmpCalc & " Hour(s) "
'the follg. will 'overflow' run time error 'tmpmins = tmpTotSEEDMins - ((tmpdays * 24 * 60) + (tmpCalc * 60)) 'the error is because if result crosses beyond integer value 'check this in immediate window ? 57 * 24 * 60 (where 57 is the tmpdays)
'so the resolution is with precision (instead of 60 we made 60.0 or 60#) then converting to clng tmpmins = tmpTotSEEDMins - (CLng(tmpdays * 24 * 60#) + (tmpCalc * 60)) 'if we type 60.0, compiler assumes 60#
'DONE FOR AUTO NO For EVERY YEAR (full block Introduced new) 'function will always send the first portion of the financial year 'i.e if 2008-09 then it will send 2008 always Public Function get_FinYear(ByVal dt_curr As Date) As Integer If Month(dt_curr) > 3 Then get_FinYear = Year(dt_curr) '==> e.g 2008-09 (from Apr 2008 to Dec 2008) Else 'if Month(Date) < 4 get_FinYear = Year(dt_curr) - 1 '==>e.g 2008-09 (from Jan 2009 to Mar 2009) End If End Function
Public Sub reNumberFlex(ByRef msfT As MSFlexGrid, ByVal intCol As Integer) 'JS 11th April 2010 For i = 1 To msfT.rows - 1 msfT.TextMatrix(i, intCol) = i Next End Sub ''Public Sub reNumberFlex1(ByRef msfT As MSFlexGrid, ByVal intCol As Integer) '''manju add on aug 2011 ''For i = 1 To msfT.rows - msfT.Row '' '' msfT.TextMatrix(i, intCol) = i ''Next ''End Sub
Public Function Remove_Braces(SrcStr As String) As String Dim TmpPlace, EndPlace As Integer Dim tmpstr, OutStr As String Dim SplStr() As String Dim i As Integer If InStr(SrcStr, ",") > 0 Then SplStr = Split(SrcStr, ",") For i = 0 To (UBound(SplStr)) If InStr(1, SplStr(i), "{") > 0 Then TmpPlace = InStr(1, SplStr(i), "{") EndPlace = InStr(SplStr(i), "}") - InStr(SplStr(i), "{") + 1 tmpstr = Mid(SplStr(i), TmpPlace, EndPlace) If TmpPlace > 0 Then OutStr = OutStr & "," & Replace(SplStr(i), tmpstr, "") Else OutStr = OutStr & "," & (SplStr(i)) End If Else OutStr = OutStr & "," & (SplStr(i)) End If Next i Remove_Braces = Right(OutStr, Len(OutStr) - 1) Else TmpPlace = InStr(1, SrcStr, "{") EndPlace = InStr(SrcStr, "}") - InStr(SrcStr, "{") + 1 tmpstr = Mid(SrcStr, TmpPlace, EndPlace) If TmpPlace > 0 Then Remove_Braces = Replace(SrcStr, tmpstr, "") Else Remove_Braces = (SrcStr) End If End If End Function Public Function Fix_userVal_ReadOnly_if_screen_already_exist1(ByVal tmpUserVal1 As Long) As Long '==================================================================== ' USAGE: ' in Multi-user Session, if two users are having save/Modify/Delete ' rights, and if two users trying to use the same screen, the second ' user's user_value(refer the userRights value) will be set to One ' i.e Read-only '==================================================================== On Error GoTo Fix_userVal_ReadOnly_if_screen_already_exist1_Err_Handler Fix_userVal_ReadOnly_if_screen_already_exist1 = tmpUserVal1 Call open_temp_rec("Select * from OnlineUsers Where UserVal>1 and SysId=" & SYS_ID & " and ScreenId<>'mdiSSI' Order By DateT") With tmp_Rec If Not .EOF Then MsgBox "Some Screens was already opened frist Close and Try Again ", vbInformation, mdiSSI.msgTxt ''''& vbLf & "User Name : " & Retrieve_Name("Select UserName from User1 Where UserId=" & .Fields("UserId")) & vbLf & "System Name : " & Retrieve_Name("Select SysName from ImpSystems Where SysId=" & .Fields("SysId")) & vbLf & "Date / Time : " & .Fields("DateT") & vbLf & "So U can't Save or Modify or Delete any record", vbCritical, mdiSSI.msgTxt Fix_userVal_ReadOnly_if_screen_already_exist1 = 1 mdiSSI.TxtlogPassWord.Visible = False mdiSSI.cmdlog.Visible = False End If End With Call close_temp_rec Exit Function Fix_userVal_ReadOnly_if_screen_already_exist1_Err_Handler: Exit Function End Function
Public Function Fix_userVal_ReadOnly_if_screen_already_exist2(ByVal tmpUserVal2 As Long) As Long '==================================================================== ' USAGE: ' in Multi-user Session, if two users are having save/Modify/Delete ' rights, and if two users trying to use the same screen, the second ' user's user_value(refer the userRights value) will be set to One ' i.e Read-only '==================================================================== On Error GoTo Fix_userVal_ReadOnly_if_screen_already_exist2_Err_Handler Fix_userVal_ReadOnly_if_screen_already_exist2 = tmpUserVal1 Call open_temp_rec("Select * from OnlineUsers Where UserVal>1 and SysId=" & SYS_ID & " and ScreenId<>'mdiSSI' Order By DateT") With tmp_Rec If Not .EOF Then MsgBox "Some Screens was already opened frist Close and Try Again ", vbInformation, mdiSSI.msgTxt ''''& vbLf & "User Name : " & Retrieve_Name("Select UserName from User1 Where UserId=" & .Fields("UserId")) & vbLf & "System Name : " & Retrieve_Name("Select SysName from ImpSystems Where SysId=" & .Fields("SysId")) & vbLf & "Date / Time : " & .Fields("DateT") & vbLf & "So U can't Save or Modify or Delete any record", vbCritical, mdiSSI.msgTxt Fix_userVal_ReadOnly_if_screen_already_exist2 = 1
mdiSSI.cmdEnter.Visible = False Else mdiSSI.cmdEnter.Visible = True End If End With Call close_temp_rec Exit Function Fix_userVal_ReadOnly_if_screen_already_exist2_Err_Handler: Exit Function End Function
Public Sub UpdateTDS(strInvNo As String, intTDSAmt As Double, PartyId As Integer) Select Case TDS_Screen Case "frmInvoiceL" 'LAB open_temp_rec ("select DebitAmt,DebitRem,Balance,debit,tds from DcOutgoingInv where invno='" & Replace(Trim(strInvNo), "'", "''") & "' and CustId =" & PartyId) With tmp_Rec If Not .EOF Then .MoveFirst While Not .EOF .Fields("TDS") = Val(intTDSAmt) .Fields("Balance") = .Fields("Balance") + .Fields("DebitAmt") - Val(intTDSAmt) .Fields("Balance") = Round(.Fields("Balance")) .Fields("DebitAmt") = Val(intTDSAmt) .Update .MoveNext Wend End If End With close_temp_rec Case "frmInvoiceSC" 'SubCon open_temp_rec ("select CreditAmt,CreditRem,Balance,Credit,TDS from DCSubConIncoming where InvNo='" & Replace(Trim(strInvNo), "'", "''") & "' and SuppId =" & PartyId) With tmp_Rec If Not .EOF Then .MoveFirst While Not .EOF .Fields("TDS") = Val(intTDSAmt) .Fields("Balance") = .Fields("Balance") + .Fields("CreditAmt") - Val(intTDSAmt) .Fields("Balance") = Round(.Fields("Balance")) .Fields("CreditAmt") = Val(intTDSAmt) .Update .MoveNext Wend End If End With close_temp_rec ' Case "frmServiceBill" 'Service ' open_temp_rec ("select DebitAmt,DebitRem,Balance,Debit,TDS from ServiceInv where InvNo='" & Replace(Trim(strInvNo), "'", "''") & "' and CustName =" & PartyId) ' With tmp_Rec ' If Not .EOF Then ' .MoveFirst ' While Not .EOF ' .Fields("TDS") = Val(intTDSAmt) ' .Fields("Balance") = .Fields("Balance") + .Fields("DebitAmt") - Val(intTDSAmt) ' .Fields("Balance") = Round(.Fields("Balance")) ' .Fields("DebitAmt") = Val(intTDSAmt) ' .Update ' .MoveNext ' Wend ' End If ' End With ' close_temp_rec End Select End Sub 4 5 6 7 8