www.pudn.com > LPT_I2C.rar > test.frm


VERSION 5.00 
Begin VB.Form Form1  
   Caption         =   "Form1" 
   ClientHeight    =   5520 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   6870 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   5520 
   ScaleWidth      =   6870 
   StartUpPosition =   3  '´°¿Úȱʡ 
   Begin VB.CommandButton Command5  
      Caption         =   "ToolTest" 
      Height          =   375 
      Left            =   840 
      TabIndex        =   6 
      Top             =   4320 
      Width           =   1455 
   End 
   Begin VB.CommandButton Command4  
      Caption         =   "λ¶Á" 
      Height          =   375 
      Left            =   4080 
      TabIndex        =   5 
      Top             =   3240 
      Width           =   1335 
   End 
   Begin VB.CommandButton Command3  
      Caption         =   "λд" 
      Height          =   375 
      Left            =   1080 
      TabIndex        =   4 
      Top             =   3240 
      Width           =   1455 
   End 
   Begin VB.CommandButton Command2  
      Caption         =   "д" 
      Height          =   495 
      Left            =   960 
      TabIndex        =   3 
      Top             =   2160 
      Width           =   1575 
   End 
   Begin VB.TextBox Text2  
      Height          =   1095 
      Left            =   600 
      TabIndex        =   2 
      Text            =   "Text2" 
      Top             =   360 
      Width           =   2295 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "¶Á" 
      Height          =   495 
      Left            =   4080 
      TabIndex        =   1 
      Top             =   2160 
      Width           =   1455 
   End 
   Begin VB.TextBox Text1  
      Height          =   1095 
      Left            =   3600 
      MultiLine       =   -1  'True 
      ScrollBars      =   3  'Both 
      TabIndex        =   0 
      Text            =   "test.frx":0000 
      Top             =   360 
      Width           =   2775 
   End 
End 
Attribute VB_Name = "Form1" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Dim flag As Boolean 
Private Sub Command1_Click() 
Dim temp As Byte 
temp = LptIic.IicReadByte(160, 0) 
If LptIic.IicError = False Then 
Text1.Text = CStr(temp) 
Else 
MsgBox "error!!!" 
End If 
 
End Sub 
 
Private Sub Command2_Click() 
LptIic.IicWriteByte 160, 0, Val(Text2.Text) 
If LptIic.IicError Then 
   MsgBox "error!!!" 
End If 
End Sub 
 
Private Sub Command3_Click() 
'Dim temp As Byte 
'temp = IicReadByte(160, 0) 
'If LptIic.IicError = False Then 
'   Text2.Text = CStr(temp) 
'Else 
'   MsgBox "error!!!" 
'End If 
If Text2.Text = "1" Then 
LptIic.SetSDA 
Else 
LptIic.ClrSDA 
End If 
End Sub 
 
Private Sub Command4_Click() 
Text1.Text = LptIic.GetSDAPort(889, 7, 0) 
End Sub 
 
Private Sub Command5_Click() 
Dim temp As Byte 
If flag = False Then 
'---------------------------------- 
If LptIic.IicBusSearch(160) Then 
   MsgBox "Iic Ok!!!" 
   flag = True 
   temp = LptIic.IicReadByte(160, 0) 
   If LptIic.IicError = False Then 
      Text1.Text = CStr(temp) 
   Else 
     MsgBox "read error!!!" 
   End If 
Else 
  MsgBox "Iic Error!!!" 
End If 
'----------------------------------- 
Else 
   temp = LptIic.IicReadByte(160, 0) 
   If LptIic.IicError = False Then 
      Text1.Text = CStr(temp) 
   Else 
     MsgBox "read error!!!" 
   End If 
End If 
End Sub 
 
Private Sub Form_Load() 
Set LptIic = New LptI2C 
Set LPTini = New LPT 
'LptIic.SDA_In_Config 889, 7, 0 
'LptIic.SDA_Out_Config 888, 0, 1 
'LptIic.SCL_In_Config 889, 6, 1 
'LptIic.SCL_Out_Config 888, 1, 1 
'LptIic.IicBusDelayTime = 1 
End Sub