⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module1.bas

📁 mmodbus
💻 BAS
字号:
Attribute VB_Name = "Module1"

Option Explicit
'播放声音的API和与之有关的常数
Public Declare Function sndPlaySound Lib "winmm.dll" _
              Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
               ByVal uFlags As Long) As Long
Public Const SND_ASYNC = &H1
Public Const SND_NODEFAULT = &H2


Public PortItem As Integer  '端口
Public DataBit As Integer  '数据位
Public BaudRate As Integer  '波特率
Public StopBit As Integer  '停止位
Public ParityCheck As Integer  '奇偶校验


Public Function GetMyFormatDate() As String  '得到****-**-**格式的日期
  Dim MyMonth As String
  Dim MyDay As String
  MyMonth = Month(Date)
  MyDay = Day(Date)
  If Len(MyMonth) = 1 Then
    MyMonth = "0" & MyMonth
  End If
  If Len(MyDay) = 1 Then
    MyDay = "0" & MyDay
  End If
  GetMyFormatDate = Year(Date) & "-" & MyMonth & "-" & MyDay
End Function
Public Function GetMyFormatTime() As String  '得到**:**格式的时间
  Dim H As String
  Dim M As String
  H = Hour(Time)
  M = Minute(Time)
  If Len(H) = 1 Then
    H = "0" & H
  End If
  If Len(M) = 1 Then
    M = "0" & M
  End If
  GetMyFormatTime = H & ":" & M
End Function
Public Function GetMyFormatDataAndTime() As String
  Dim DataAndTime As String
  DataAndTime = GetMyFormatDate & "  " & GetMyFormatTime
  GetMyFormatDataAndTime = DataAndTime
End Function
Public Sub DoMySleep(a As Double)      '延时函数,a 为秒
  Dim t   As Date
  t = DateAdd("s", a, Now)
  Do While Now < t
      DoEvents
  Loop
End Sub
'用来播放声音的子过程
Public Sub PlaySound(strSound As String)
  sndPlaySound strSound, SND_ASYNC Or SND_NODEFAULT
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -