PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Accessing form's text box from Module

Reply

Accessing form's text box from Module

 
Thread Tools Rate Thread
Old 07-01-2007, 03:08 AM   #1
Elmo Watson
Guest
 
Posts: n/a
Default Accessing form's text box from Module


I have come from a VB6 background, and I'm trying to convert an MDI app that
has many subs in modules which directly access
a textbox in a child form of the main MDI form (frmMain as MDI form, frmEdit
as child form, txtEdit as richtextbox)
code:
With frmMain.ActiveMdiChild.txtEdit

I totally understand OO concepts now, which I didn't (completely) when the
app was originally written, but I really don't want to re-write every single
sub and make it a function, to output text - that would make me want to
shoot the computer.
I guess, the other option would be to put all this stuff in the MDI form or
MDI child, however, that would really bloat those forms....(IMHO)

Is there a way to reference the textbox on the child form, directly inside a
module, with VB.Net (2005)?


  Reply With Quote
Old 07-01-2007, 03:24 AM   #2
Stephany Young
Guest
 
Posts: n/a
Default Re: Accessing form's text box from Module

You mean like?:

Module xyz

Public Sub UpdateRichTextBox()

CType(CType(Application.OpenForms("frmMain"), frmMain).ActiveMdiChild,
frmEdit).txtEdit.Text = "The quick brown fox ..."

End Sub

End Module


"Elmo Watson" <sputnik75043@NOSpam.yahoo.com> wrote in message
news:ubqpjkgMHHA.4708@TK2MSFTNGP02.phx.gbl...
>I have come from a VB6 background, and I'm trying to convert an MDI app
>that has many subs in modules which directly access
> a textbox in a child form of the main MDI form (frmMain as MDI form,
> frmEdit as child form, txtEdit as richtextbox)
> code:
> With frmMain.ActiveMdiChild.txtEdit
>
> I totally understand OO concepts now, which I didn't (completely) when the
> app was originally written, but I really don't want to re-write every
> single sub and make it a function, to output text - that would make me
> want to shoot the computer.
> I guess, the other option would be to put all this stuff in the MDI form
> or MDI child, however, that would really bloat those forms....(IMHO)
>
> Is there a way to reference the textbox on the child form, directly inside
> a module, with VB.Net (2005)?
>



  Reply With Quote
Old 07-01-2007, 05:05 AM   #3
Elmo Watson
Guest
 
Posts: n/a
Default Re: Accessing form's text box from Module

Absolutely great! I've been looking for this for so long

I just dimmed that all as a RichTextBox at the head of the Module and
everything went perfectly

Thanks! - You're a life saver

"Stephany Young" <noone@localhost> wrote in message
news:upzYbtgMHHA.3312@TK2MSFTNGP03.phx.gbl...
> You mean like?:
>
> Module xyz
>
> Public Sub UpdateRichTextBox()
>
> CType(CType(Application.OpenForms("frmMain"),
> frmMain).ActiveMdiChild, frmEdit).txtEdit.Text = "The quick brown fox ..."
>
> End Sub
>
> End Module
>
>
> "Elmo Watson" <sputnik75043@NOSpam.yahoo.com> wrote in message
> news:ubqpjkgMHHA.4708@TK2MSFTNGP02.phx.gbl...
>>I have come from a VB6 background, and I'm trying to convert an MDI app
>>that has many subs in modules which directly access
>> a textbox in a child form of the main MDI form (frmMain as MDI form,
>> frmEdit as child form, txtEdit as richtextbox)
>> code:
>> With frmMain.ActiveMdiChild.txtEdit
>>
>> I totally understand OO concepts now, which I didn't (completely) when
>> the app was originally written, but I really don't want to re-write every
>> single sub and make it a function, to output text - that would make me
>> want to shoot the computer.
>> I guess, the other option would be to put all this stuff in the MDI form
>> or MDI child, however, that would really bloat those forms....(IMHO)
>>
>> Is there a way to reference the textbox on the child form, directly
>> inside a module, with VB.Net (2005)?
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off