Solved

use control from module

Posted on 2004-10-21
14
196 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

911 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

20 Experts available now in Live!

Get 1:1 Help Now