在两个应用程序VB之间传递字符串 [英] Passing string between 2 applications VB

查看:94
本文介绍了在两个应用程序VB之间传递字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是编码新手。

我正在寻找一个例子,我找不到我需要的东西。

我找到的最多的例子,第一个应用程序执行应用程序2并传递文本。

我需要应用程序2一直打开,我需要应用程序1只发送给应用程序2数据。



任何帮助??



我尝试过:



Sender App:

Dim strText As String

strText =hello

Shell(c:ReceiverX。 exe& strText,[vbNormalFocus])



Riceiver App:

Dim strText2 As String

strText2 = Command()

Label1.Text = strText2

解决方案

请参阅Socket类:套接字类(System.Net.Sockets) [ ^ ]

从评论开始到问题。你是绝对正确的。一旦程序或进程使用或使用它,文件就会被锁定。这将只留下一个程序一次访问该文件,其余的必须等到资源被释放。



但是,既然你提到许多发件人和只有一个接收者,我建议您在中构建这些应用程序客户端 - 服务器模型 [ ^ ]基础。这将允许您的应用程序请求数据,服务器将返回数据;这样只有服务器才能访问该文件,并且不会担心任何锁(除非您的服务器以异步模式工作)。


Hello guys, am new at coding.
I was searching alot for an example an i cant find what i need.
The most examples that i found, the first application executes the application 2 and passing the text.
I need the Application 2 opened all the time, and i need the Application 1 send to Application 2 only the data.

any help??

What I have tried:

Sender App:
Dim strText As String
strText = "hello"
Shell("c:ReceiverX.exe " & strText, [vbNormalFocus])

Riceiver App:
Dim strText2 As String
strText2 = Command()
Label1.Text = strText2

解决方案

See the Socket class: Socket Class (System.Net.Sockets)[^]


Starting from the comments to the question. You are absolutely right. Files are locked when once program or process is consuming it or using it. This will leave only one program to access the file at a time, and the rest would have to wait until the resource is freed.

However, since you mention many senders and only one receiver, I would like to suggest that you build these applications in a Client-server model[^] basis. That would allow your applications to request the data and the server would return the data; this way only server has to access the file at all and there won't be any locks to worry about (unless your server works in asynchronous pattern).


这篇关于在两个应用程序VB之间传递字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆