機房收費系統——函數

來源:互聯網
上載者:User




 

'消費金額的計算Public Function Consume(consumeTime As Long, Money As Long)    '儲存基本資料設定資訊    Dim leastTime As Long ‘定義至少上機時間    Dim UnitTime As Long’定義單位遞增時間    Dim preTime As Long’定義準備時間    Dim rateMoeny As Long’定義固定單位時間的費用    Dim limitCash As Long’定義最少金額            Dim mrc As ADODB.Recordset '定義臨時記錄集    Dim MsgText As String '定義字串    Dim txtSQL As String '定義查詢條件字串        '讀取設定基本資料資訊    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    '消費時間最少為設定值    If consumeTime < leastTime Then        consumeTime = leastTime    End If    '消費函數       Money = Int(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()         '該函數返回電腦名稱   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 sTokens() As String      On Error GoTo executeSQL_Error      sTokens = Split(SQL)   Set cnn = New ADODB.Connection   cnn.Open ConnectString      If InStr("insert,delete,update", UCase$(sTokens(0))) Then '非select 語句    '函數返回字元或字串在另一個字串中第一次出現的位置       cnn.Execute SQL  '資料量不大時,可以在串連上,直接執行SQL語句       MsgString = sTokens(0) & "query successful"       '雖然Msgstring不是返回值,但傳遞方式是ByRef,實參地址和這個地址相同   Else     Set rst = New ADODB.Recordset         rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic     '得到暫存資料表,遊標指向第一條記錄     'get recordCount,     Set ExecuteSQL = rst     MsgString = "查詢到" & rst.RecordCount & _           "條記錄"   End If   executeSQL_Exit:   Set rst = Nothing   Set cnn = Nothing    Exit Function   executeSQL_Error:   MsgString = "查詢錯誤:" & Err.Description     '對錯誤進行簡短描述。當無法處理或不想處理錯誤的時候,可以使用這個屬性提醒使用者。     Resume executeSQL_Exit '啟動一個錯誤處理程式並指定該子程式在一個過程中的位置    End Function

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


 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.