Solved

use control from module

Posted on 2004-10-21
14
190 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--
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 50 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Setting location of a form 4 22
AutoHotkey ActiveX Component Error 8 55
Hide Tab Page 3 18
Get String split 5 32
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now