PC Review


Reply
Thread Tools Rate Thread

Simple question regarding modules

 
 
RSH
Guest
Posts: n/a
 
      25th Jul 2005
Hi,

i have a situation where I have a VB .Net Module built that contains all of
the functions I need. I now need to add a form to the project and i need
the form to sdisplay and the module code to write to the form. I am having
trouble figuring out how to do this.

Basically, I have Form1 which contains a button and a TextBox. Module1
contains a function called Function1. I want to attach an event to the
button which will call Function1 in the Module1 which in turn will display a
simple line of text to the TextBox on Form1

This is the code I have:

Sub in Module1...

Public Sub initialTest()

MessageBox.Show("hi")

Dim oForm = New Form1

oForm.RTB1.text = "Hi"

System.Windows.Forms.Application.DoEvents()

End Sub





Button Click in Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Module1.initialTest()

End Sub



The event is getting to Module1 and displaying the messagebox, but I get an
error "Public member 'TextBox' on type Form1 Not Found"



What needs to be done?



Thanks,

RSH


 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      25th Jul 2005
RSH wrote:
> Hi,
>
> i have a situation where I have a VB .Net Module built that contains all of
> the functions I need. I now need to add a form to the project and i need
> the form to sdisplay and the module code to write to the form. I am having
> trouble figuring out how to do this.
>
> Basically, I have Form1 which contains a button and a TextBox. Module1
> contains a function called Function1. I want to attach an event to the
> button which will call Function1 in the Module1 which in turn will display a
> simple line of text to the TextBox on Form1
>
> This is the code I have:
>
> Sub in Module1...
>
> Public Sub initialTest()
>
> MessageBox.Show("hi")
>
> Dim oForm = New Form1
>
> oForm.RTB1.text = "Hi"
>
> System.Windows.Forms.Application.DoEvents()
>
> End Sub
>
>
>
>
>
> Button Click in Form1
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
> Module1.initialTest()
>
> End Sub
>
>
>
> The event is getting to Module1 and displaying the messagebox, but I get an
> error "Public member 'TextBox' on type Form1 Not Found"
>
>
>
> What needs to be done?
>
>
>
> Thanks,
>
> RSH
>
>


To do this you need to make a public property on form1 that will accept
a string. In that property assign the RTB1.text property.

Public Property RTB1Text() as String
Get
return RTB1.Text
End Get
Set(ByVal Value as String)
RTB1.Text = Value
End Set
End Property

The problem you are having the way you are doing it is that RTB1 is
private on Form1 and therefor cannot be accessed by anything outside of
Class Form1

Hope it helps
Chris
 
Reply With Quote
 
RSH
Guest
Posts: n/a
 
      28th Jul 2005
Okay another silly question...now that i set that up how do i access it? I
get an error "Reference to a non-shared member requires an object reference.

Form1.RTB1Text = "TESTING"



Thanks!


"Chris" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> RSH wrote:
>> Hi,
>>
>> i have a situation where I have a VB .Net Module built that contains all
>> of the functions I need. I now need to add a form to the project and i
>> need the form to sdisplay and the module code to write to the form. I am
>> having trouble figuring out how to do this.
>>
>> Basically, I have Form1 which contains a button and a TextBox. Module1
>> contains a function called Function1. I want to attach an event to the
>> button which will call Function1 in the Module1 which in turn will
>> display a simple line of text to the TextBox on Form1
>>
>> This is the code I have:
>>
>> Sub in Module1...
>>
>> Public Sub initialTest()
>>
>> MessageBox.Show("hi")
>>
>> Dim oForm = New Form1
>>
>> oForm.RTB1.text = "Hi"
>>
>> System.Windows.Forms.Application.DoEvents()
>>
>> End Sub
>>
>>
>>
>>
>>
>> Button Click in Form1
>>
>> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles Button1.Click
>>
>> Module1.initialTest()
>>
>> End Sub
>>
>>
>>
>> The event is getting to Module1 and displaying the messagebox, but I get
>> an error "Public member 'TextBox' on type Form1 Not Found"
>>
>>
>>
>> What needs to be done?
>>
>>
>>
>> Thanks,
>>
>> RSH
>>
>>

>
> To do this you need to make a public property on form1 that will accept a
> string. In that property assign the RTB1.text property.
>
> Public Property RTB1Text() as String
> Get
> return RTB1.Text
> End Get
> Set(ByVal Value as String)
> RTB1.Text = Value
> End Set
> End Property
>
> The problem you are having the way you are doing it is that RTB1 is
> private on Form1 and therefor cannot be accessed by anything outside of
> Class Form1
>
> Hope it helps
> Chris



 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple simple question about command-prompt window riprap Windows XP General 9 6th Nov 2008 03:55 PM
Compile modules question =?Utf-8?B?TGlsTW9yZVBsZWFzZQ==?= Microsoft Access 2 12th Nov 2006 08:39 PM
Basic question - modules and class modules - what's the difference? Mark Stephens Microsoft Excel Programming 9 8th May 2005 12:48 PM
Question regarding Modules Lis'a Microsoft Access VBA Modules 3 15th Jan 2004 06:47 PM
question on class modules George Microsoft Access VBA Modules 0 16th Jul 2003 06:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:39 PM.