Data room charging system-Function

Source: Internet
Author: User

 

 

'Public Function Consume (consumeTime As Long, Money As Long) 'Save basic data settings Dim leastTime As long' defines at least the machine time Dim UnitTime As long' defines the unit increment time Dim preTime As long' defines the preparation time Dim rateMoeny As long' defines a fixed unit dim limitCash As Long defines the minimum Dim mrc As ADODB. recordset 'defines the temporary record Set Dim MsgText As string' defines the String Dim txtSQL As string' defines the query condition string' read the Set basic data information txtSQL = "select * from basicdata_info" Set mrc = ExecuteSQL (txtSQL, msgText) mrc. moveLast rateMoeny = mrc. fields (0) 'txtlh. text = mrc. fields (1) UnitTime = mrc. fields (2) leastTime = mrc. fields (3) preTime = mrc. fields (4) limitCash = mrc. fields (5) mrc. close 'minimum consumption time is set value If consumeTime <leastTime Then consumeTime = leastTime End If 'Consumption Function Money = Int (consumeTime-preTime)/UnitTime + 1) * (rateMoeny/30 * UnitTime) Consume = Money End Function

PublicDeclare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As LongPublic Function getPcName () 'This Function returns the computer Name Dim Name As String, length As Long Length = 255 Name = String (Length, 0) GetComputerName Name, Length Name = Left (Name, Length) getPcName = NameEnd Function

PublicFunction ExecuteSQL (ByVal SQL As String, MsgString As String) AsADODB. recordset 'executes SQL and returns Recordest Dim cnn As ADODB. connection Dim rst As ADODB. recordset Dim metrics ens () As String On Error GoTo executeSQL_Error metrics ens = Split (SQL) Set cnn = New ADODB. connection cnn. open ConnectString If InStr ("insert, delete, update", UCase $ (ENS ens (0) Then 'non-select statement' function returns the first occurrence of a character or string in another string Location of cnn. execute SQL 'when the data volume is small, you can directly Execute the SQL statement MsgString = ens (0) & "query successful" 'on the connection. Although Msgstring is not the return value, the passing method is ByRef, the real parameter address is the same as this address Else Set rst = New ADODB. recordset rst. open Trim $ (SQL), cnn, adOpenKeyset, adLockOptimistic 'to get a temporary table. The cursor points to the first record 'get recordCount, Set ExecuteSQL = rst MsgString = "" & rst. recordCount & _ "record" End If executeSQL_Exit: Set rst = Nothing Set cnn = Nothing Exit Function e XecuteSQL_Error: MsgString = "query error:" & Err. Description "briefly describes the error. You can use this attribute to remind users when they cannot process or do not want to handle errors. Resume executeSQL_Exit 'start an error handler and specify the position of this subroutine in a process. End Function

Public Function Testtxt(txt As String) AsBoolean   If Trim(txt) = "" Then       Testtxt = False   Else       Testtxt = True    End If   End Function


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.