?
Solved

use control from module

Posted on 2004-10-21
14
Medium Priority
?
227 Views
Last Modified: 2010-04-23
this is probably a very simple question

i just got vb.net enterprise architect edition and im having a hard time getting my head around all the new features

how do i access a control on a form through a module

like in vb6 for example it was form1.winsocksend.senddata data

how do i do this in vb.net

thanks --Laser--
0
Comment
Question by:--laser--
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
14 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12367522
Well you could give the sub the form as an argument
or set the form as a global variable
or if you know the window handle to could get it that way
0
 
LVL 4

Author Comment

by:--laser--
ID: 12367533
isnt there anything simpler like form1.winsocksend.senddata data


i have this code in vb6 and need it to run in vb.net

public sub Send (data as string)
    form1.winsocksend.senddata data
    doevents
end sub


this code is just in a module
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12367634
No sorry, Vb6 and VB.net are very different in that aspect. But if you set form1 as a global variable you could do it that way
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Author Comment

by:--laser--
ID: 12367647
how would i set it as a global variable, as i said i am very new to vb.net

thanks
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12367736
Just a couple of questions, because setting a form as a global variable isn't actually the proper way to do things in .net, it is just a workaround.

Is your form1 your startup form ?
When and where are you calling the sub in your module
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12367851
I posted a comment on your earlier message

Pass the object of Winsock to the function in the module that's the most elegant and easy way.

If there's any hitch in it you can post the specific detail
0
 
LVL 4

Author Comment

by:--laser--
ID: 12368188
ronaldbiemans

form1...yes it is startup
i call the sub in the module whenever i want to send a string through the winsock control
its just easier then typin winsocksend.senddata data
doevents
every time i want to send something because there is a lot of things to be sent


arif egbal, could you show me an example of how to pass the winsock to the fuction in the module please

im just getting used to vb.net and it is a lot diffrent to vb6 so im sure you understand if im asking silly simple questions :-)
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12368227
do you call the sub in the module just from form1 or from different forms?
0
 
LVL 4

Author Comment

by:--laser--
ID: 12368238
hmm....

actually it will be 2 seperate forms form1 and form2 but the winsock control resides on form1
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 200 total points
ID: 12368291
If you are calling the Module method from Form1 and the Winsock Control is on Form2 then I am afraid you can't pass the object as an argument because Form1 will have the same problems accessing Winsock as the Module is having

What I can suggest is have a module Level variable in your module and on the Form Load of form2 set it equal to your winsock object

Now Module will use this control through the object reference in the variable.

Also on Closed event of Form2 set the module variable to Nothing.

And be careful in you module do error checcking before using the variable whether it references to the control or it is Nothing.

0
 
LVL 4

Author Comment

by:--laser--
ID: 12368379
ok i have changed my mind this sounds a bit to complicated for me at this stage

i will put the sub into form1 and leave out some features on form2

only thing is that doevents doesn't work in vb.net ! !

is there still a need for doevents command?
0
 
LVL 4

Author Comment

by:--laser--
ID: 12368394
ok i worked that one out...        System.Windows.Forms.Application.DoEvents()
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12368627
You already have the reference to
System.Windows.Forms

So just Application.DoEvents() will do
0
 
LVL 4

Author Comment

by:--laser--
ID: 12368640
i tried that already but it didnt seem to work,anyway the long way works so im happy :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question