Form Control Update from Module

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Running a VB.Net windows application. Using a module to parse data in a
file. How do I pass information back to the form for display?

This does not work from the module:

dim frm as form1
frm.txtbox.txt = "my data"

This also does not work from module:

dim frm as form1
frm.ShowData("my data")

and in form1:

public sub ShowData(byval Info as string)
txtbox.txt = Info

Thanks.
 
Running a VB.Net windows application. Using a module to parse data in a
file. How do I pass information back to the form for display?

You could call your module parser from the form as a function that returns a
string. Or as a sub with one or more byref parameters.
This does not work from the module:
dim frm as form1
frm.txtbox.txt = "my data"

In form1's load event handler, put
frm=me
This will work assuming the form gets started before the module parsing
finishes.
 
This does not work from the module:
In form1's load event handler, put
frm=me
This will work assuming the form gets started before the module parsing
finishes.

Be advised, in the module you need
Public frm as form1
rather than
Dim frm as form1
I use Dim only inside subs and functions, otherwise I (usually) use Public
or Private.
 
Placed frm=me in form1 load event handler

Placed Public frm as form1 in module

Placed frm.txtbox.text = "my data" in a subroutine of the module.

A button on the form goes to the module subroutine which does some http
actions and returns a string to be sent to the text box.

The above does not work. What else could I be doing wrong? Thanks.
 
Placed frm=me in form1 load event handler
Placed Public frm as form1 in module
Placed frm.txtbox.text = "my data" in a subroutine of the module.
A button on the form goes to the module subroutine which does some http
actions and returns a string to be sent to the text box.
The above does not work. What else could I be doing wrong? Thanks.

Describe 'does not work'. Does it compile ok? When run, does it blow up?
If so, how? Does it run without any errors but still fails to update the
text box?

Do you know how to use the debugger? Can you set a breakpoint in your
module where you try to set the textbox and see if you get there?
 
I apologize for being vague.

What you provided does work.

I forgot to take an old line of code out that was effecting the txtbox.

Thanks.
 
Back
Top