473,761 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET: Receive string from the module and use it to the form

Hi

Does anyone know how to stay connected to the server and at the same time i
can pass the string to and from the module to the form.....

What I want:

I put the connection at the module.....

1)I can pass the string from the form to the module...
(Because there is send and receiveInfo method from the server so i put both
methods to the module)
2)I receive that string from the module and pass it to the form...
3)The form will show that string to the textbox...

But now step 3 can't work...
It receive nothing from the module..

Any idea how to use correct it..... or i implement wrongly...

Now i can only display the contents at the Start of a new form through the
module as MessageBox when i receive from the server...

But can't display it to the textbox in the form because can't pass the
string from the module to the form...

Thanks
--------------------------------------------------------------------
My Codes:

In the previous form....

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
receiveInfo()
Me.Hide()
End Sub
-------------------------------------------------------------------

In the Module....

Public Name As String

Public Sub send(ByVal s As String)

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim sendBytes As Byte()
sendBytes = ascii.GetBytes( s)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Catch ex As Exception
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.")
End Try
End Sub
----------------------------------------------------------------------------
--
Public Sub receiveInfo()

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
MessageBox.Show (ret)

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.")
End Try
End Sub

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum
Nov 21 '05 #1
4 2726
Hi,

Try something like this.

In the module

Public function receiveInfo() as string

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
return ret

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.")
return "An error has occured"
End Try
End Sub

In the form

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
frm.textbox1.te xt = receiveInfo()
Me.Hide()
End Sub

Ken
----------------------------
"http://www.visual-basic-data-mining.net/forum" <si******@gmail .com> wrote
in message news:ur******** ******@TK2MSFTN GP12.phx.gbl...
Hi

Does anyone know how to stay connected to the server and at the same time i
can pass the string to and from the module to the form.....

What I want:

I put the connection at the module.....

1)I can pass the string from the form to the module...
(Because there is send and receiveInfo method from the server so i put both
methods to the module)
2)I receive that string from the module and pass it to the form...
3)The form will show that string to the textbox...

But now step 3 can't work...
It receive nothing from the module..

Any idea how to use correct it..... or i implement wrongly...

Now i can only display the contents at the Start of a new form through the
module as MessageBox when i receive from the server...

But can't display it to the textbox in the form because can't pass the
string from the module to the form...

Thanks
--------------------------------------------------------------------
My Codes:

In the previous form....

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
receiveInfo()
Me.Hide()
End Sub
-------------------------------------------------------------------

In the Module....

Public Name As String

Public Sub send(ByVal s As String)

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim sendBytes As Byte()
sendBytes = ascii.GetBytes( s)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Catch ex As Exception
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.")
End Try
End Sub
----------------------------------------------------------------------------
--
Public Sub receiveInfo()

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
MessageBox.Show (ret)

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.")
End Try
End Sub

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum

Nov 21 '05 #2
oh......I will try it..

another problem is that the frm.textbox1.te xt is in another form...

that means it is not declared yet..

now to declare it from another form..

Thanks..

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Try something like this.

In the module

Public function receiveInfo() as string

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
return ret

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.") return "An error has occured"
End Try
End Sub

In the form

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
frm.textbox1.te xt = receiveInfo()
Me.Hide()
End Sub

Ken
----------------------------
"http://www.visual-basic-data-mining.net/forum" <si******@gmail .com> wrote
in message news:ur******** ******@TK2MSFTN GP12.phx.gbl...
Hi

Does anyone know how to stay connected to the server and at the same time i can pass the string to and from the module to the form.....

What I want:

I put the connection at the module.....

1)I can pass the string from the form to the module...
(Because there is send and receiveInfo method from the server so i put both methods to the module)
2)I receive that string from the module and pass it to the form...
3)The form will show that string to the textbox...

But now step 3 can't work...
It receive nothing from the module..

Any idea how to use correct it..... or i implement wrongly...

Now i can only display the contents at the Start of a new form through the
module as MessageBox when i receive from the server...

But can't display it to the textbox in the form because can't pass the
string from the module to the form...

Thanks
--------------------------------------------------------------------
My Codes:

In the previous form....

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
receiveInfo()
Me.Hide()
End Sub
-------------------------------------------------------------------

In the Module....

Public Name As String

Public Sub send(ByVal s As String)

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim sendBytes As Byte()
sendBytes = ascii.GetBytes( s)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Catch ex As Exception
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.") End Try
End Sub
-------------------------------------------------------------------------- -- --
Public Sub receiveInfo()

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
MessageBox.Show (ret)

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.") End Try
End Sub

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum

Nov 21 '05 #3
For the answer that you send me can works...

what about my previous question that i post...

how to solve it..

Thanks a lot..

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Try something like this.

In the module

Public function receiveInfo() as string

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
return ret

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.") return "An error has occured"
End Try
End Sub

In the form

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
frm.textbox1.te xt = receiveInfo()
Me.Hide()
End Sub

Ken
----------------------------
"http://www.visual-basic-data-mining.net/forum" <si******@gmail .com> wrote
in message news:ur******** ******@TK2MSFTN GP12.phx.gbl...
Hi

Does anyone know how to stay connected to the server and at the same time i can pass the string to and from the module to the form.....

What I want:

I put the connection at the module.....

1)I can pass the string from the form to the module...
(Because there is send and receiveInfo method from the server so i put both methods to the module)
2)I receive that string from the module and pass it to the form...
3)The form will show that string to the textbox...

But now step 3 can't work...
It receive nothing from the module..

Any idea how to use correct it..... or i implement wrongly...

Now i can only display the contents at the Start of a new form through the
module as MessageBox when i receive from the server...

But can't display it to the textbox in the form because can't pass the
string from the module to the form...

Thanks
--------------------------------------------------------------------
My Codes:

In the previous form....

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
receiveInfo()
Me.Hide()
End Sub
-------------------------------------------------------------------

In the Module....

Public Name As String

Public Sub send(ByVal s As String)

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim sendBytes As Byte()
sendBytes = ascii.GetBytes( s)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Catch ex As Exception
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.") End Try
End Sub
-------------------------------------------------------------------------- -- --
Public Sub receiveInfo()

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
MessageBox.Show (ret)

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.") End Try
End Sub

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum

Nov 21 '05 #4
That means if that textbox is within the same form, it can display after i
receive it..

But if the textbox is in another form after i receive, it cannot work.

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum
"http://www.visual-basic-data-mining.net/forum" <si******@gmail .com> wrote
in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
For the answer that you send me can works...

what about my previous question that i post...

how to solve it..

Thanks a lot..

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Try something like this.

In the module

Public function receiveInfo() as string

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
return ret

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the server.")
return "An error has occured"
End Try
End Sub

In the form

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e

As
System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
frm.textbox1.te xt = receiveInfo()
Me.Hide()
End Sub

Ken
----------------------------
"http://www.visual-basic-data-mining.net/forum" <si******@gmail .com> wrote in message news:ur******** ******@TK2MSFTN GP12.phx.gbl...
Hi

Does anyone know how to stay connected to the server and at the same time i
can pass the string to and from the module to the form.....

What I want:

I put the connection at the module.....

1)I can pass the string from the form to the module...
(Because there is send and receiveInfo method from the server so i put

both
methods to the module)
2)I receive that string from the module and pass it to the form...
3)The form will show that string to the textbox...

But now step 3 can't work...
It receive nothing from the module..

Any idea how to use correct it..... or i implement wrongly...

Now i can only display the contents at the Start of a new form through

the module as MessageBox when i receive from the server...

But can't display it to the textbox in the form because can't pass the
string from the module to the form...

Thanks
--------------------------------------------------------------------
My Codes:

In the previous form....

Private Sub btnNextActivity _Click(ByVal sender As System.Object, ByVal e

As
System.EventArg s) Handles btnNextActivity .Click

Dim s As String
Dim dd As New form2
dd.Show()

Connect()
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "></Fruit>"
send(s)
receiveInfo()
Me.Hide()
End Sub
-------------------------------------------------------------------

In the Module....

Public Name As String

Public Sub send(ByVal s As String)

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim sendBytes As Byte()
sendBytes = ascii.GetBytes( s)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Catch ex As Exception
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the

server.")
End Try
End Sub


--------------------------------------------------------------------------
--
--
Public Sub receiveInfo()

Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream

Try
networkStream = tcpC.GetStream( )
Dim bytes(tcpC.Rece iveBufferSize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpC.Recei veBufferSize))
Dim ret As String = ascii.GetString (bytes)
MessageBox.Show (ret)

Catch
Console.WriteLi ne("Sorry. This NetWorkStream is not connect to the

server.")
End Try
End Sub

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6703
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
2
2765
by: Chad | last post by:
I'm in an intro to VB.net class. I'm haveing trouble with this assignment, if anyone could help me please let me know. thanks! Coding Assignment 7-Chapter 8 OOP-CSCI-171 Intro to VB.NET 1. Create a Windows application that models a carton of eggs: Define a public class and call it cEggCarton to model the egg carton. Declare a module-scope object variable of type cEggCarton. Since we want the object to persist throughout the life...
7
4263
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant" value="Merchant Name"> <input type="hidden" name="OrderID" value="Unique OrderID value"> <input type="hidden" name="email" value="Customers email address (OPTIONAL)">
5
2735
by: Peter Proost | last post by:
Hi I got this piece of c# code which runs ok but now I translated it to vb.net (see bottom of post for both pieces) and it keeps erroring out at pi.SetValue(testForm, newValue, x) with this error: System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean...
1
3463
by: Marek Murin | last post by:
Hi all, I have created vb.net user control that has to be used by vb6 form. Everything goes well with putting the vb.net user control on the VB6 form until I want to receive any event from my control. The event handler is displayed on VB6 IDE combo and you can create a sub for it as usual, but when I run the vb6 form to test it, it won't work. I have spent too much time til now with that without finding solution. Can anybody help me ?
0
3668
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. · When was the first version of .NET released? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on...
0
3842
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which allows you to program accordingly. · What are user controls and custom controls? Custom controls: A control authored by a user or a third-party software vendor that...
3
1636
by: al-s | last post by:
I have a working VB.NET 2005 (.NET2.0) solution that works. When I translate the code modules, form modules to C# I get all sorts of build errors, much of which are related to scoping of methods. I have the following given in a form module: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
10
6247
by: Jan Vinten | last post by:
Hi all, I got into some trouble trying to bind to a specific IP address. Code: Private mobjClient As TcpClient mobjClient = New TcpClient(IPAddress.Parse("10.16.104.87").ToString, 8892)
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.