Display value of textbox

Solved
grotone Posted messages 14 Registration date   Status Member -  
lermite222 Posted messages 9042 Status Contributor -
Hello,

I have a little question that is probably not too complicated but is causing me some trouble anyway.
I have a procedure that takes a string as a parameter representing the name of a textbox on my sheet, and I'm trying to display a message with the value contained in the textbox whose name is passed as a parameter.

Sub Test(name As String)
MsgBox Sheets("Sheet1").name.Value
End Sub

But it doesn't work, probably because it's not a string that it takes for the name variable...

Thanks in advance

See you later

Grotone
Configuration: Windows 2003 Internet Explorer 6.0

2 answers

lermite222 Posted messages 9042 Status Contributor 1 199
 
Hello,
if it can help you...
Sub Test(obj As MSForms.TextBox) MsgBox obj.Text End Sub Sub testertest() Test Sheets("feuil1").TextBox1 End Sub

See you!
1
gbinforme Posted messages 14930 Registration date   Status Contributor Last intervention   4 744
 
Hello

For the syntax, you need to use:

MsgBox Sheets("Sheet1").Shapes(name).Name

But as you can see, I've used the "Name" property (which you know and is therefore unnecessary) because the "Value" or "Text" properties are not accessible.

By working with text boxes on the sheet that I'm not using, it seems that you cannot manage the content in VBA.

You might want to try using a "userform" sheet where it is very easy to do so.
--

Always zen
0