By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,133 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,133 IT Pros & Developers. It's quick & easy.

UserForm <-> Module TextBox share

P: n/a
Simple question. I'm a VBA programmer who has just switched to VB .net. I'm
using a UserForm called Form1 with a text box called TextBox1.

I'd like to reference the number in the text box in the module called Engine
by using the following statement

Dim num as Double
num = Form1.TextBox1.Value

However, I can not see the TextBox1 after I finish typing "Form1". What's
going on?
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Marknanh,

Start setting option strict on in top of your program, in the beginning it
will give some problems and than you can for a while set it to off. Using it
helps you to find errors and gives programs which process faster.

The code
Dim num as Double
num = Form1.TextBox1.Value

should be

Dim num as Double
num = Cdbl(me.TextBox1.Text)

Which says

Set the value in the textbox in my class (me), which is your form, as a
double value in the field num.

I hope this helps?

Cor
Nov 21 '05 #2

P: n/a
On Wed, 8 Sep 2004 15:03:08 -0700, Marknanh wrote:
Simple question. I'm a VBA programmer who has just switched to VB .net. I'm
using a UserForm called Form1 with a text box called TextBox1.

I'd like to reference the number in the text box in the module called Engine
by using the following statement

Dim num as Double
num = Form1.TextBox1.Value

However, I can not see the TextBox1 after I finish typing "Form1". What's
going on?


In addition to Cor's comment, is "Form1" the name of the instance of your
form? Or is it the name of the form class?

In other words, did you do something like this anywhere:

Dim Form1 As New UserForm

num = Form1.TextBox1.Text

If Form1 is the name of your form *class* then you must get the value of
the textbox using an *instance* of the class and not the class name.

HTH a little

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.