#1   Report Post  
Kevin
 
Posts: n/a
Default VBA Objects

I need to take a string variable passed into a
subroutine, concatenate it with another string, and then
have this string represent an object name so I can
manipulate the Enabled and Value properties of the
already existing object.
  #3   Report Post  
 
Posts: n/a
Default

Not a class assignment, a work necessity. I've never
studied VBA formally -- learning it on the fly. I have
named all related controls (on a UserForm) with the same
ending. For instance, if I have a label and check box
that go together, they will be named lblXXX and chkXXX.
What I am trying to do is to write a generic subroutine
that would allow me to pass the value of XXX into the
subroutine, and the sub would add the lbl and chk
prefixes to the string and then manipulate the Enabled
and Value properties of those controls. This would be
much more efficient than what I'm writing now --
individual subroutines for each group of controls.

Thanks
-----Original Message-----
And the assignment is due when?

--
Don Guillett
SalesAid Software

"Kevin" wrote in message
...
I need to take a string variable passed into a
subroutine, concatenate it with another string, and

then
have this string represent an object name so I can
manipulate the Enabled and Value properties of the
already existing object.



.

  #4   Report Post  
Kevin
 
Posts: n/a
Default

So am I to assume that what I'm asking isn't possible?
-----Original Message-----
And the assignment is due when?

--
Don Guillett
SalesAid Software

"Kevin" wrote in message
...
I need to take a string variable passed into a
subroutine, concatenate it with another string, and

then
have this string represent an object name so I can
manipulate the Enabled and Value properties of the
already existing object.



.

  #5   Report Post  
Jim Cone
 
Posts: n/a
Default

Kevin,

Maybe something like the following...
'-------------------------------
Private Sub CheckBox1_Click()
ThisIsATest (CheckBox1.Name)
End Sub

Private Sub Label1_Click()
ThisIsATest (Label1.Name)
End Sub

Sub ThisIsATest(ByRef S As String)
MsgBox S
End Sub
'---------------------------------

Jim Cone
San Francisco, USA


"Kevin" wrote in message
...
So am I to assume that what I'm asking isn't possible?




  #7   Report Post  
Kevin
 
Posts: n/a
Default

Thanks - I'll give it a try!

Kevin
-----Original Message-----
I put this in a General module:

Option Explicit
Public myStr As String
Sub testme()
myStr = "xxx"
UserForm1.Show
End Sub


And this behind the userform1:

Option Explicit
Private Sub UserForm_Initialize()
Dim ctrl As Control
For Each ctrl In Me.Controls
With ctrl
If LCase(.Name) Like "*" & myStr Then
With ctrl
.Visible = True
.Enabled = False
End With
End If
End With
Next ctrl
End Sub

wrote:

Not a class assignment, a work necessity. I've never
studied VBA formally -- learning it on the fly. I have
named all related controls (on a UserForm) with the

same
ending. For instance, if I have a label and check box
that go together, they will be named lblXXX and chkXXX.
What I am trying to do is to write a generic subroutine
that would allow me to pass the value of XXX into the
subroutine, and the sub would add the lbl and chk
prefixes to the string and then manipulate the Enabled
and Value properties of those controls. This would be
much more efficient than what I'm writing now --
individual subroutines for each group of controls.

Thanks
-----Original Message-----
And the assignment is due when?

--
Don Guillett
SalesAid Software

"Kevin" wrote in message
...
I need to take a string variable passed into a
subroutine, concatenate it with another string, and

then
have this string represent an object name so I can
manipulate the Enabled and Value properties of the
already existing object.


.


--

Dave Peterson
.

  #8   Report Post  
Harald Staff
 
Posts: n/a
Default

If I understand your question right:

Private Sub CommandButton1_Click()
'set chcABCD.value to False, and
'set txtABCD.text to Yo da man:
Call Test("ABCD")
End Sub

Sub Test(sName As String)
UserForm1.Controls("chc" & sName).Value = False
UserForm1.Controls("txt" & sName).Text = "Yo da man"
End Sub

HTH. Best wishes Harald

skrev i melding
...
Not a class assignment, a work necessity. I've never
studied VBA formally -- learning it on the fly. I have
named all related controls (on a UserForm) with the same
ending. For instance, if I have a label and check box
that go together, they will be named lblXXX and chkXXX.
What I am trying to do is to write a generic subroutine
that would allow me to pass the value of XXX into the
subroutine, and the sub would add the lbl and chk
prefixes to the string and then manipulate the Enabled
and Value properties of those controls. This would be
much more efficient than what I'm writing now --
individual subroutines for each group of controls.

Thanks
-----Original Message-----
And the assignment is due when?

--
Don Guillett
SalesAid Software

"Kevin" wrote in message
...
I need to take a string variable passed into a
subroutine, concatenate it with another string, and

then
have this string represent an object name so I can
manipulate the Enabled and Value properties of the
already existing object.



.



  #9   Report Post  
Kevin
 
Posts: n/a
Default

Yo ABSOLUTELY da man! This was exactly what I was looking
for.

Thanks for the help.

Kevin


-----Original Message-----
If I understand your question right:

Private Sub CommandButton1_Click()
'set chcABCD.value to False, and
'set txtABCD.text to Yo da man:
Call Test("ABCD")
End Sub

Sub Test(sName As String)
UserForm1.Controls("chc" & sName).Value = False
UserForm1.Controls("txt" & sName).Text = "Yo da man"
End Sub

HTH. Best wishes Harald

skrev i melding
...
Not a class assignment, a work necessity. I've never
studied VBA formally -- learning it on the fly. I have
named all related controls (on a UserForm) with the

same
ending. For instance, if I have a label and check box
that go together, they will be named lblXXX and chkXXX.
What I am trying to do is to write a generic subroutine
that would allow me to pass the value of XXX into the
subroutine, and the sub would add the lbl and chk
prefixes to the string and then manipulate the Enabled
and Value properties of those controls. This would be
much more efficient than what I'm writing now --
individual subroutines for each group of controls.

Thanks
-----Original Message-----
And the assignment is due when?

--
Don Guillett
SalesAid Software

"Kevin" wrote in message
...
I need to take a string variable passed into a
subroutine, concatenate it with another string, and

then
have this string represent an object name so I can
manipulate the Enabled and Value properties of the
already existing object.


.



.

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
Excel 97 Protect but allow comments sally t Excel Discussion (Misc queries) 7 December 21st 04 10:53 PM
Vlookup / Objects help XL2003 Steve Jones Excel Discussion (Misc queries) 0 November 29th 04 05:01 PM


All times are GMT +1. The time now is 06:59 AM.

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

About Us

"It's about Microsoft Excel"