|
-
Sep 24th, 2004, 03:07 AM
#1
Thread Starter
Addicted Member
VB.NET:Loading XML string to the Start of a new form after receiving from the module
Hi
how do load the information to the new form when i click next in the previous form..
say i put my connection in the Module..
I pass the string of Xml tag at form1 to the module through send() method and receive the result to the MessageBox in form2 through receiveInfo() method in the module....
why is it that the messageBox i receive is blank without the string
"<Fruit> & vFruit & Name </Fruit>" in it....
how to link the Xml tag to the MessageBox in form2....
(Use MessageBox to simulate that it can receive and link to form2 when it start a new form)
Thanks..
In the previous form....
Code:
Private Sub btnNextActivity_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 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....
Code:
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.Write(sendBytes, 0, sendBytes.Length)
Catch ex As Exception
Console.WriteLine("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.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpC.ReceiveBufferSize))
Dim ret As String = ascii.GetString(bytes)
MessageBox.Show(ret)
Catch
Console.WriteLine("Sorry. This NetWorkStream is not connect to the server.")
End Try
End Sub
Last edited by toytoy; Dec 3rd, 2004 at 08:12 AM.
-
Sep 24th, 2004, 04:13 AM
#2
Thread Starter
Addicted Member
Ai ya....solve it
forget to close the string "></Fruit>"...
-
Sep 24th, 2004, 04:26 AM
#3
Thread Starter
Addicted Member
anyone has any idea how to display the Xml tag to the textbox in form2 instead of MessageBox from the module....
Thanks
-
Sep 24th, 2004, 04:29 AM
#4
Originally posted by toytoy
anyone has any idea how to display the Xml tag to the textbox in form2 instead of MessageBox from the module....
Thanks
hello actually i dont know about xml.
but did you try textbox1.text='your xml tag'??
instead of messagebox.show()?
-
Sep 24th, 2004, 04:41 AM
#5
Thread Starter
Addicted Member
yeah...cannot
the thing is i declare the "Name" in the module as string
then put a string to the Name in form1....
which means i put under the receiveInfo() method in the module
as
Name = ret
below
Dim ret As String = ascii.GetString(bytes)
and it receive none....it cannot get the tags out to display to form2..
any ways to extract the string out from the module and use it to the form....
Thanks..
Last edited by toytoy; Sep 24th, 2004 at 10:47 PM.
-
Sep 24th, 2004, 10:45 PM
#6
Thread Starter
Addicted Member
VB.NET: Receive string from the module and use it to the form
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 and 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
Last edited by toytoy; Sep 25th, 2004 at 01:59 AM.
-
Sep 25th, 2004, 08:11 AM
#7
Thread Starter
Addicted Member
I solve it.....
In the module...
Code:
Public Name As String
Public function receiveInfo() As String
Dim ascii As Encoding = Encoding.ASCII
Dim networkStream As NetworkStream
Try
networkStream = tcpC.GetStream()
Dim bytes(tcpC.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpC.ReceiveBufferSize))
Dim ret As String = ascii.GetString(bytes)
Return ret
Catch
Console.WriteLine("Sorry. This NetWorkStream is not connect to the server.")
End Try
End Sub
In the previous from..
Code:
Private Sub btnNextActivity_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextActivity.Click
Connect()
Dim s As String
Dim dd As New form2
dd.Show()
Me.Hide()
End Sub
In the next form......
Code:
Private Sub form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim s As String
Name = "Apple"
s = "<Fruit Type=" & """" & Name & """" & "</Fruit>"
send(s)
txtReceive.Text = receiveInfo()
End Sub
Last edited by toytoy; Dec 3rd, 2004 at 08:10 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|