鱼C论坛

 找回密码
 立即注册
查看: 3016|回复: 0

[迷途问路] vb 串口

[复制链接]
发表于 2012-10-6 20:37:07 | 显示全部楼层 |阅读模式
9鱼币
請教各位先進,我有一個程式為兩端互傳資料,但在call ftfunc副程式時,會產生沒有定義
錯誤,我將其g_buftab()定義成long or byte,皆會產生另一api錯誤訊息,請教原因或解決方式,為何?以下是副程式部份!!!

Public Const gmem_fixed = &H0
Declare Function globalalloc Lib "kernel32" (ByVal wflags As Long, ByVal dwbytes As Long) As Long
Declare Function globallock Lib "kernel32" (ByVal hmem As Long) As Long

Declare Function globalfree Lib "kernel32" (ByVal hmem As Long) As Long
Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpstring As Long) As Long
Declare Function lstrcpyn Lib "kernel32" Alias "lstrcpynA" (ByVal lpString1 As String, ByVal lpString2 As Long, ByVal iMaxLength As Long) As Long



Public Function xcallback(ByVal xmitlen As Long, ByVal buflen As Long, ByVal buf As Long, ByVal flen As Long) As Long

On Error Resume Next
DoEvents
Call Form1.Refreshstate(xmitlen, flen, gxfname)


xcallback = 0

End Function

Public Function rcallback(ByVal recvlen As Long, ByVal buflen As Long, ByVal buf As Long, ByVal flen As Long) As Long
On Error Resume Next
DoEvents
Call lstrcpn(grfname, g_buftab(0), lstrlen(g_buftab(0)) + 1)
DoEvents
Form1.Text1 = App.Path & "\" & grfname

Call Form1.Refreshstate(recvlen, flen, grfname)

rcallback = 0



End Function
Public Sub ftfunc(port As Long, direction As Integer)

Dim ret As Long


If (direction = 0) Then
ret = sio_FtZmodemTx(port, grfname, AddressOf xcallback, 27)
Else
g_buftab(0) = globallock(globalalloc(gmem_fixed, max_path + 1))
Call lstrcpy(g_buftab(0), "")
End If

If ret < 0 Then
MsgBox "傳送/接收失敗", vbCritical + vbOKOnly, "warming"
Else
If (direction = 0) Then


MsgBox "傳送完成", vbInformation + vbOKOnly, "Send_message"
Else
MsgBox "接收完成", vbInformation + vbOKOnly, "Receive_message"
End If
End If








End Sub

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-11-21 23:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表