vb程序代码向c++builder得翻译
以下是几个vb函数 请给出C++builder得转换后函数代码
Public Function waits(delay) // 靠循环等时
Dim k As Long
Dim kk As Long
For k = 0 To delay
For kk = 0 To 1000
Next kk
Next k
End Function
Public Function detectspead(delay As Long, testi As Integer, word As String) As String //测速函数
Dim rasc As Integer
Dim rl As Integer
Dim rh As Integer
Dim k As Long
Dim kk As Long
rh = USB_GetStatus() - 64
If rh > 1 Then
USB_SetControl (1)
Call waits(delay)
rl = USB_GetStatus() - 64
rasc = rh * 16 + rl
word = word + Chr(rasc)
word = Right(word, 9)
If word = "123456789" Then
sInt = USB_Outport(8, 0)
USB_SetControl (0)
Call waits(delay)
sInt = USB_Outport(0, 0)
detectspead = "ok"
Exit Function
End If
If testi = 9 And word <> "123456789" Then
testi = 1
delay = 100 + delay
End If
Call waits(delay)
testi = testi + 1
USB_SetControl (0)
End If
End Function
Public Function receive(delay) As String //接收函数
Dim rasc As Integer
Dim rl As Integer
Dim rh As Integer
Dim k As Long
Dim kk As Long
rh = USB_GetStatus() - 64
If rh > 1 Then
USB_SetControl (1)
For k = 0 To delay
For kk = 0 To 1000
Next kk
Next k
rl = USB_GetStatus() - 64
rasc = rh * 16 + rl
receive = Chr(rasc)
USB_SetControl (0)
For k = 0 To delay
For kk = 0 To 1000
Next kk
Next k
End If
End Function
Public Function send(sendword As String) // 发送函数
Dim clong As Integer
Dim cl As Integer
Dim ch As Integer
Dim casc As Integer
clong = Len(sendword)
For i = 1 To clong
casc = Asc(Mid(sendword, i, 1))
ch = casc \ 16
cl = casc Mod 16
USB_SetControl (cl)
sInt = USB_Outport(8, 0)
Call wait
USB_SetControl (ch)
sInt = USB_Outport(0, 0)
Call wait
Next i
USB_SetControl (1)
sInt = USB_Outport(8, 0)
Call wait
USB_SetControl (0)
sInt = USB_Outport(0, 0)
Call wait
End Function
Function wait() //等待函数
Dim hover As Integer
hover = USB_GetStatus() - 64
If hover = 1 Then
End If
End Function
着急呢 谢谢!!!
问题点数:10、回复次数:1Top
1 楼daydayup234(关中刀客)回复于 2006-06-03 15:37:26 得分 0
/*
Public Function waits(delay) // 靠循环等时
Dim k As Long
Dim kk As Long
For k = 0 To delay
For kk = 0 To 1000
Next kk
Next k
End Function
*/
void waits(long delay)
{
long k;
long kk;
for(k=0;k<delay;k++)
for(kk=0;kk<1000;kk++){}
}Top




