求助:翻译短信收发控件VB.NET源码
在调试短信猫。前日在“sunhongwu”的帮助下,得到了DLL的VB源码及答疑,帖子已结。现还有一个使用OCX控件的,厂家只有支持VB.NET的二次开发包,而我仅会VFP,现请求高手将其中的调用alasunsmscon.ocx控件及其连接短信猫、接收、发送短信等VB源码告知,我试着将其转换为VFP。谢谢。
现将厂家给的支持VB.NET的二次开发包用WINRAR压缩后上传,文件很小,只有40.4K。
http://www.vdisk.cn/down/index/15206044
短信 vb
[解决办法]
其中的代码不难阿,打开后出错的,是意思是转为VB?
[解决办法]
vb.net所有代码如下:
先要注册控件:regsvr32.exe c:\windows\system32\alasunsmscon.ocx
Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
Axalasunsms1.CommPort = Val(txtCommPort.Text)
If Axalasunsms1.OpenComm() = 0 Then
Axalasunsms1.SetMsgCenterNo(txtMsgCenter.Text)
cmdConnect.Enabled = False
cmdDisConnect.Enabled = True
cmdSend.Enabled = True
cmdRead.Enabled = True
MsgBox("设备打开成功")
Else
MsgBox("设备打开失败")
End If
End Sub
Private Sub cmdDisConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDisConnect.Click
If Axalasunsms1.CloseComm = 0 Then
cmdConnect.Enabled = True
cmdDisConnect.Enabled = False
cmdSend.Enabled = False
cmdRead.Enabled = False
MsgBox("设备关闭成功")
Else
MsgBox("设备关闭失败")
End If
End Sub
Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSend.Click
Dim lngMsgType As Long
If chkBlink.Checked Then
lngMsgType = lngMsgType + 2
End If
If chkFlash.Checked Then
lngMsgType = lngMsgType + 4
End If
If Axalasunsms1.SendMsg(txtNo.Text, txtCon.Text, "", lngMsgType, False) = 0 Then
MsgBox("发送成功")
Else
MsgBox("发送成功")
End If
End Sub
Private Sub Axalasunsms1_OnReceive(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Axalasunsms1.OnReceive
Dim sNo As String, sCon As String, sMsgCenterNo As String
Dim dSendTime As Date, lTimeZone As Integer
If Axalasunsms1.ReadMsg(sNo, sCon, sMsgCenterNo, dSendTime, lTimeZone) = 0 Then
txtReceive.Text = dSendTime & "收到来自" & sNo & "的短信,短信中心号:" & sMsgCenterNo & "内容:" & sCon
End If
End Sub
Private Sub cmdRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRead.Click
Dim sNo As String, sCon As String, sMsgCenterNo As String
Dim dSendTime As Date, lTimeZone As Integer
If Axalasunsms1.ReadMsgByIndex(CInt(txtIndex.Text), sNo, sCon, sMsgCenterNo, dSendTime, lTimeZone) = 0 Then
txtFromNo.Text = CStr(sNo)
txtSendTime.Text = CStr(dSendTime)
txtReadCon.Text = CStr(sCon)
End If
End Sub