Sending data to another forms' sub

jai

Newcomer
Joined
Sep 1, 2006
Messages
1
hi,

Wonder if anyone can point me in the right direction...(VB.net 2005)

Im trying to send data from formB to FormA's sendstuff sub...

but getting and error on -> sw.Write(sdata & vbCr)
Object reference not set to an instance of an object. And something about using "New"??? "Use the New keyword to create the instance"

Its probably something basic, but after days of searching im now blind as to what im looking for :s

Any help is much appreciated :)

Jai


parts from FormA:
Visual Basic:
Imports System.Net.Sockets
Public Class FormA

    Public tcp As TcpClient
    Dim netstream As NetworkStream
    Dim sr As IO.StreamReader
    Dim sw As IO.StreamWriter
    Dim identdThread As Threading.Thread

Public Sub x1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles x1.Click
        tcp = New TcpClient()
        tcp.Connect("irc.blahblah.com", 6667)
        netstream = tcp.GetStream
        sr = New IO.StreamReader(netstream, System.Text.Encoding.ASCII)
        sw = New IO.StreamWriter(netstream, System.Text.Encoding.ASCII)
        Timer1.Enabled = True
        sw.WriteLine("NICK " + nick.Text)
        sw.Flush()
        sw.WriteLine("USER . . . .")
        sw.Flush()

Public Sub sendstuff(ByVal sdata As String)

        sw.Write(sdata & vbCr)
        sw.Flush()
End Sub
parts from FormB:
Visual Basic:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        FormA.sendstuff("PRIVMSG #test test")
    End Sub
 
Last edited by a moderator:
Back
Top