分数肯定的再加,关键是高手你能否拿得到
kw123 2003-08-15 10:59:58 我现在有一千九百多分,遇到一个难题。对于高手来说是不难的。请告诉我它的工作流程和程序解释说明。(我是用pb,bcb,c的).分数肯定加
一:窗体程序
' EZ-USB Bulk Transfer Example
' copyright (c) 2000 Cypress Semiconductor
'
' file: frmBulk.frm
Option Explicit
Public strBuffer As String
Private Sub Form_Load()
Dim Index As Integer
Dim sDriverName As String
Dim hDriver As Long
' find all the attached EZ-USB devices and
' add them to the devices drop-down list
For Index = 0 To MAX_USB_DEV_NUMBER - 1
sDriverName = "Ezusb-" & Index
hDriver = OpenDriver(sDriverName)
If hDriver > 0 Then
cmbDriverName.AddItem sDriverName
CloseHandle hDriver
End If
Next
If cmbDriverName.ListCount > 0 Then
cmbDriverName.Text = cmbDriverName.List(0)
Else
ErrMsg (eBadDriver)
End
End If
End Sub
Private Sub Label1_Click(Index As Integer)
End Sub
Private Sub txtIn_Change()
Dim buffer(63) As Byte
Dim result As Long
Dim i As Integer
Dim lDataLen As Long
Dim sDriverName As String
' keep track of new text added to input text
strBuffer = strBuffer + Right(txtIn, 1)
' have we hit the "xfer trigger"?
If Len(strBuffer) = Val(txtBlkSize.Text) Then
' put new string data into byte buffer
lDataLen = Len(strBuffer)
For i = 1 To lDataLen
buffer(i - 1) = Asc(Mid(strBuffer, i, 1))
Next
strBuffer = ""
sDriverName = cmbDriverName.Text
' write the data to the EZ-USB board
result = DoBulkXfer(sDriverName, eWrite, buffer, lDataLen)
If result <> 1 Then: ErrMsg (result): Exit Sub
' clear out buffer
For i = 0 To 63 ' no rabbits up my sleeve
buffer(i) = 0
Next
' get text back from EZ-USB board
result = DoBulkXfer(sDriverName, eRead, buffer, lDataLen)
If result <> 1 Then: ErrMsg (result): Exit Sub
' move characters from buffer to output text area
For i = 1 To lDataLen
txtOut.Text = txtOut.Text + Chr(buffer(i - 1))
Next
End If ' xfer trigger reached
End Sub
Private Sub txtBlkSize_Change()
Dim temp As Integer
' coerce input to text representing number between 1 and 64
temp = Val(txtBlkSize)
If temp < 0 Or temp > 64 Then
MsgBox "Enter a valid Bulk Transfer block size between 1 and 64.", vbInformation, "Input Error"
txtBlkSize.SelStart = 0
txtBlkSize.SelLength = 3
End If
End Sub
Private Sub cmdClearIn_Click()
txtIn.Text = ""
End Sub
Private Sub cmdClearOut_Click()
txtOut.Text = ""
End Sub
Private Sub Form_Activate()
txtBlkSize.SetFocus
End Sub