Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Referring to a TextBox

I am programmatically trying extract text from a known textbox.

Using Textboxes from the Control Toolbox, I know that this works:

ActiveSheet.EditBox.Text = ActiveSheet.TextBox1.Text

I have tried a number of variations of the following without success:

Sub TestLoad()
Dim F1 As TextBox
Set F1.Name = "TextBox" & "2"
ActiveSheet.EditBox.Text = ActiveSheet.F1.Text
End Sub

How can I programmatically 'build' the textbox name so that I can refer
to it ?

Any help appreciated.

Andrew B
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Referring to a TextBox


You have to set F1 to the complete textbox not to a part of it


Code:
--------------------
Sub TestLoad()
Dim F1 As TextBox
Set F1= TextBox2
ActiveSheet.EditBox.Text = ActiveSheet.F1.Text
End Sub
--------------------


but you want to select wich textbox to select on the run so you need to
use a control. I'm assuming you are placing this code in a form...


Code:
--------------------
Sub TestLoad()
Dim Ct as Control
Dim F1 As TextBox

for each Ct in Me.Controls
if Ct.name = "Textbox" & YourNumber then
Set F1= Ct
exit for
end if
next
ActiveSheet.EditBox.Text = ActiveSheet.F1.Text
End Sub
--------------------


--
Dnereb
------------------------------------------------------------------------
Dnereb's Profile: http://www.excelforum.com/member.php...o&userid=26182
View this thread: http://www.excelforum.com/showthread...hreadid=398086

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Referring to a TextBox

Hi
I can't seem to get things working yet. I am not running this code from
a form, just from a normal module.
Any other suggestions ?
Thanks
Andrew B

Dnereb wrote:
You have to set F1 to the complete textbox not to a part of it


Code:
--------------------
Sub TestLoad()
Dim F1 As TextBox
Set F1= TextBox2
ActiveSheet.EditBox.Text = ActiveSheet.F1.Text
End Sub
--------------------


but you want to select wich textbox to select on the run so you need to
use a control. I'm assuming you are placing this code in a form...


Code:
--------------------
Sub TestLoad()
Dim Ct as Control
Dim F1 As TextBox

for each Ct in Me.Controls
if Ct.name = "Textbox" & YourNumber then
Set F1= Ct
exit for
end if
next
ActiveSheet.EditBox.Text = ActiveSheet.F1.Text
End Sub
--------------------


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
Referring to a TextBox Andrew B[_4_] Excel Programming 1 August 22nd 05 10:34 PM
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys Minitman[_4_] Excel Programming 0 February 22nd 05 08:50 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:43 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 04:55 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"