Prikazi cijelu temu 04.04.2014 18:12
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Lokacija:Tuzla


Predmet:Re: Clasa Vo Access
PreuzmiIzvorni kôd (Visual Basic):
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Dim mComm As MSComm
  5. Dim m_PortOpen As Boolean
  6. Dim m_Settings As String
  7. Dim m_CommPort As Integer
  8. Dim m_DTREnable As Boolean
  9. Dim m_Handshaking As FlowControl
  10. Dim m_InBufferSize As Integer
  11. Dim m_InputLen As Integer
  12. Dim m_InputMode As Mode
  13. Dim m_OutBufferSize As Integer
  14. Dim m_RTSEnable As Boolean
  15. Dim m_CommEvent As Integer
  16.  
  17.  
  18.     Const None = 0
  19.     Const XonXoff = 1
  20.     Const CTSRTS = 2
  21.     Const XonXoffCTSRTS = 3
  22.  
  23.  
  24.  
  25.    Const Text = 0
  26.    Const Binary = 1
  27.  
  28.  
  29. Public Sub Output(Dat As Variant)
  30.   mComm.Output = Dat
  31. End Sub
  32.  
  33. Public Property Get InBufferCount() As Integer
  34.   InBufferCount = mComm.InBufferCount
  35. End Property
  36.  
  37. Public Property Get InputData() As Variant
  38.   InputData = mComm.Input
  39. End Property
  40.  
  41. Public Property Get OutBufferCount() As Integer
  42.     OutBufferCount = mComm.OutBufferCount
  43. End Property
  44.  
  45. Public Property Let PortOpen(ByVal NewValue As Boolean)
  46.     If m_PortOpen = False And NewValue = True Then
  47.         With mComm
  48.             .ParityReplace = ""
  49.             .Settings = m_Settings
  50.             .CommPort = m_CommPort
  51.             .DTREnable = m_DTREnable
  52.             .Handshaking = m_Handshaking
  53.             .InBufferSize = m_InBufferSize
  54.             .InputLen = m_InputLen
  55.             .InputMode = m_InputMode
  56.             .OutBufferSize = m_OutBufferSize
  57.             .RTSEnable = m_RTSEnable
  58.             .PortOpen = True
  59.         End With
  60.         m_PortOpen = True
  61.     ElseIf NewValue = False Then
  62.         mComm.PortOpen = False
  63.         m_PortOpen = False
  64.     End If
  65. End Property
  66.  
  67. Public Property Get PortOpen() As Boolean
  68.     PortOpen = m_PortOpen
  69. End Property
  70.  
  71. Private Sub Class_Initialize()
  72.     m_Settings = "9600, N, 8, 1"
  73.     m_CommPort = 1
  74.     m_InBufferSize = 1024
  75.     m_OutBufferSize = 1024
  76.     Set mComm = CreateObject("MSCOMMLIB.MSCOMM")
  77. End Sub
  78.  
  79. Public Property Get CommPort() As Integer
  80.     CommPort = m_CommPort
  81. End Property
  82.  
  83. Public Property Let CommPort(ByVal NewValue As Integer)
  84.     m_CommPort = NewValue
  85.     If m_PortOpen = True Then mComm.CommPort = NewValue
  86. End Property
  87.  
  88. Public Property Get DTREnable() As Boolean
  89.     DTREnable = m_DTREnable
  90. End Property
  91.  
  92. Public Property Let DTREnable(ByVal NewValue As Boolean)
  93.     m_DTREnable = NewValue
  94.     If m_PortOpen = True Then mComm.DTREnable = NewValue
  95. End Property
  96.  
  97. Public Property Get Handshaking() As FlowControl
  98.     Handshaking = m_Handshaking
  99. End Property
  100.  
  101. Public Property Let Handshaking(ByVal NewValue As FlowControl)
  102.     m_Handshaking = NewValue
  103.     If m_PortOpen = True Then mComm.Handshaking = NewValue
  104. End Property
  105.  
  106. Public Property Get InBufferSize() As Integer
  107.     InBufferSize = m_InBufferSize
  108. End Property
  109.  
  110. Public Property Let InBufferSize(ByVal NewValue As Integer)
  111.     m_InBufferSize = NewValue
  112.     If m_PortOpen = True Then mComm.InBufferSize = NewValue
  113. End Property
  114.  
  115. Public Property Get InputLen() As Integer
  116.     InputLen = m_InputLen
  117. End Property
  118.  
  119. Public Property Let InputLen(ByVal NewValue As Integer)
  120.     m_InputLen = NewValue
  121.     If m_PortOpen = True Then mComm.InputLen = NewValue
  122. End Property
  123.  
  124. Public Property Get InputMode() As Mode
  125.     InputMode = m_InputMode
  126. End Property
  127.  
  128. Public Property Let InputMode(ByVal NewValue As Mode)
  129.     m_InputMode = NewValue
  130.     If m_PortOpen = True Then mComm.InputMode = NewValue
  131. End Property
  132.  
  133. Public Property Get OutBufferSize() As Integer
  134.     OutBufferSize = m_OutBufferSize
  135. End Property
  136.  
  137. Public Property Let OutBufferSize(ByVal NewValue As Integer)
  138.     m_OutBufferSize = NewValue
  139.     If m_PortOpen = True Then mComm.OutBufferSize = NewValue
  140. End Property
  141.  
  142. Public Property Get RTSEnable() As Boolean
  143.     RTSEnable = m_RTSEnable
  144. End Property
  145.  
  146. Public Property Let RTSEnable(ByVal NewValue As Boolean)
  147.     m_RTSEnable = NewValue
  148.     If m_PortOpen = True Then mComm.RTSEnable = NewValue
  149. End Property
  150.  
  151. Public Property Get CDHolding() As Boolean
  152.     If m_PortOpen = True Then CDHolding = mComm.CDHolding
  153. End Property
  154.  
  155. Public Property Get CTSHolding() As Boolean
  156.     If m_PortOpen = True Then CTSHolding = mComm.CTSHolding
  157. End Property
  158.  
  159. Public Property Get DSRHolding() As Boolean
  160.     If m_PortOpen = True Then DSRHolding = mComm.DSRHolding
  161. End Property
  162.  
  163. Private Sub Class_Terminate()
  164.     Set mComm = Nothing
  165. End Sub
  166.  
  167. Public Property Get CommEvent() As Integer
  168.     CommEvent = m_CommEvent
  169. End Property
  170.  
  171. Private Sub mComm_OnComm()
  172.     m_CommEvent = mComm.CommEvent
  173.     m_CommEvent = 0
  174. End Sub
  175.  
  176. Public Property Get RThreshold() As Integer
  177.     RThreshold = mComm.RThreshold
  178. End Property
  179.  
  180. Public Property Let RThreshold(ByVal NewValue As Integer)
  181.     mComm.RThreshold = NewValue
  182. End Property

Podrška samo putem foruma, jer samo tako i ostali imaju koristi od toga.