Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using The Text From A Textbox In A UserForm

I think I have broken the back of programming OptionBoxes and
ComboBoxes in userforms but am trying to use the text entered into a
textbox. I have the text box to initially show "x" but want the user
to change this and then save it to a variable. I can get round this
by using the .controlsource referncing a cell but want to use a
variable instead. This is my code:-

Dim Tempform
Public NewTextBox As MSForms.TextBox ' In Declarations
Public c as String ' In Declarations
Dim X As Integer

Set Tempform=ThisWorkbook.VBProject.VBComponents.Add(3 )
Set NewTextBox=TempForm.Designer.Controls.Add("forms.T extBox.1")
With NewTextBox
.text="x"
End With

Set NewCommandButton1=.........("forms.CommandButton.1 ")

With Tempform.CodeModule
X = .CountOfLines
.InsertLines X + 1, "Sub CommandButton1_Click"
.InsertLines X + 2, " c=NewTextbox.Text"
.InsertLines X + 3, " Unload Me"
.InsertLines X + 4, "End Sub"
End With

This always gives me c="x". Can anybody tell me what I am doing
wrong?
Thanks, as always!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Using The Text From A Textbox In A UserForm

As an addition to the above I do show the form using
VBA.UserForms.Add(Tempform.Name).Show

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Using The Text From A Textbox In A UserForm

As usual..post a question and then immediately sort it out!
.InsertLines X + 2, " c=Textbox1.value"
works!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM
Qn: Display Text in TextBox in Userform Michael Vaughan Excel Programming 1 August 18th 04 05:06 PM
Textbox in userform shaharul[_6_] Excel Programming 3 April 15th 04 12:54 PM
formatting text in TextBox in UserForm Kevin Excel Programming 2 November 7th 03 01:34 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"