calling a sub from another form?

dynamic_sysop

Senior Contributor
Joined
Oct 1, 2002
Messages
1,039
Location
Ashby, Leicestershire.
hi could someone tell me if it's possible to call a sub from 1 form when it's on another like you could in vb6?
for example on my mdi parent form i have a socket and from the child form i want to send text from a textbox through the socket, if i try something like frmMain. it doesnt show the socket obviously as it's only made on that form and not public for the whole project, so i have tried a seperate sub on the parent form ( Public Sub SendData(sndData as String)
with socket
if .connected = true then
.senddata(.StringToBytes(sndData & vbcrlf)
end if
end with
end sub
******************
now in vb6 if i put that on a form then from another form i could call it by say frmMain.SendData( strdata )
but with .net it wont work:confused:
any help on this would be appreciated ty.
 
s'ok i figured it out lol
Dim frm3 As New Form1()
If e.KeyCode = Keys.Enter Then
frm3.SendData(txtSend.Text)
End If
thats in the child forms txtsend_KeyDown sub
and also i had Dim WithEvents Socket As SocketsClient()
and then in form load socket = new socketsclient
this was throwing it all out, so i changed the code at the top of the form to Dim WithEvents Socket As New SocketsClient() and it works ok now
 
Back
Top