[英]Connecting B4A Android Application to Desktop using VB6
I am using basic4android and have created an application which simply stores and pushes all mobile phone keystrokes. 我正在使用basic4android并创建了一个应用程序,只需存储和推送所有手机按键。 This is functioning when I storing and dumping the data remotely online, however I am attempting to store the data to display on a listening vb6 form application.
当我在线远程存储和转储数据时,这是有效的,但是我试图将数据存储在监听vb6表单应用程序上。 Basically each time a new record of X number of words is triggered, it should simply display that text block on my running VB form label.
基本上每次触发X个单词的新记录时,它应该只在我运行的VB表单标签上显示该文本块。 Please note I am using a usb cable from the device to the PC.
请注意我使用从设备到PC的USB电缆。 Sorry about the noob question.
抱歉,这个菜鸟问题。
How can I push data from my android device to my listening VB6 form app via USB? 如何通过USB将数据从我的Android设备推送到我的监听VB6表单应用程序?
Thanks. 谢谢。
This is a tricky one, since it is not obvious what is the driver that is talking to the android phone. 这是一个棘手的问题,因为与Android手机通话的驱动程序并不明显。 If you are lucky, the driver maps itself to a COM port.
如果幸运的话,驱动程序会将自身映射到COM端口。 For instance, on my box, the "Samsung Mobile USB Modem #2" device maps itself to COM4.
例如,在我的盒子上,“Samsung Mobile USB Modem#2”设备将自身映射到COM4。
If your device is using a COM port mapping, then add the Microsoft Comm Control to your Components list. 如果您的设备使用COM端口映射,则将Microsoft Comm Control添加到组件列表中。 Simple code which waits for input forever, and writes to Debug.Print is as follows:
永远等待输入的简单代码,写入Debug.Print如下:
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = "4" ' <=== "1" = COM1, "2" = COM2, "3" = COM3, "4" = COM4
MSComm1.Settings = "1200,n,8,1" ' You can probably replace 1200 with a much higher value, e.g. 230400
MSComm1.RThreshold = 1
MSComm1.InputLen = 1
MSComm1.PortOpen = True
Do
DoEvents
Debug.Print MSComm1.Input
Loop Until False
If the driver uses other mechanisms, this will be a lot more complicated, and require messing around with drivers and the Windows API - not for the faint-hearted. 如果驱动程序使用其他机制,这将更加复杂,并且需要搞乱驱动程序和Windows API - 不适合胆小的人。
Like Mark Bertenshaw said, although I wouldn't loop to obtain the data but use the OnComm() event: 就像Mark Bertenshaw所说,虽然我不会循环获取数据但使用OnComm()事件:
Private Sub MSComm1_OnComm()
Dim strInput As String
Select Case MSComm1.CommEvent
Case comEvReceive
strInput = MSComm1.Input
Debug.Print strInput
End Select
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.