Module1.bas
Upload User: lzd18710
Upload Date: 2009-11-26
Package Size: 3595k
Code Size: 1k
Category:

Communication

Development Platform:

Visual Basic

  1. Attribute VB_Name = "Module1"
  2. Public connFP As New ADODB.Connection
  3. Public recFP As New ADODB.Recordset
  4. Public week(6) As String
  5. Function Str2Byte(s As String, Index As Long) As Byte
  6.     Dim b1 As Byte, b2 As Byte
  7.     Dim s1 As String, s2 As String
  8.     
  9.     s1 = Mid(s, Index * 2 + 1, 1)
  10.     s2 = Mid(s, Index * 2 + 2, 1)
  11.     If s1 >= "A" Then
  12.         b1 = Asc(s1) - Asc("A") + 10
  13.     Else
  14.         b1 = Asc(s1) - Asc("0")
  15.     End If
  16.     If s2 >= "A" Then
  17.         b2 = Asc(s2) - Asc("A") + 10
  18.     Else
  19.         b2 = Asc(s2) - Asc("0")
  20.     End If
  21.     Str2Byte = b1 * 16 + b2
  22. End Function
  23. Function Str2ByteArray(s As String, b() As Byte) As Integer
  24.     Dim i As Long
  25.     Dim l As Long
  26.     
  27.     l = Len(s) / 2
  28.     For i = 0 To l - 1 Step 1
  29.         b(i) = Str2Byte(s, i)
  30.     Next
  31.     Str2ByteArray = l
  32. End Function