Prikazi cijelu temu 04.04.2014 01:30
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Lokacija:Ohrid Makedonija


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