---
title: "Use a String As Object Name"  
description: "Use a String As Object Name"  
author: "Anonymous User"  
published: 2013-06-11  
updated: 2013-06-12  
canonical: https://www.mindstick.com/forum/1035/use-a-string-as-object-name  
category: "vb.net"  
tags: ["vb.net"]  
reading_time: 1 minute  

---

# Use a String As Object Name

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs), \
How can I change a [picture box](https://www.mindstick.com/forum/23034/picture-box-with-3-partitions-and-partitions-should-be-controlled-with-numeric-updown)'s [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) when I only have a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) that has the [name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide) of the picture box. (it probably doesn't [really matter](https://yourviews.mindstick.com/view/85689/does-rahul-gandhi-name-really-matter-to-indians) that it's a picture box or that I am changing it's image)\
For example:\
**"picturebox1".image = myimage** \
how would I get this to actually set an image for **picturebox1**?\
Any help on above is really appreciated.

## Replies

### Reply by AVADHESH PATEL

Hi Everyone,\
Used **CType** in place of **DirectCast** and write following line of code

```
Dim pb As PictureBox = DirectCast(Me.Controls.Find("picturebox1", True).FirstOrDefault(),  PictureBox)If pb IsNot Nothing Then    pb.Image = myimageEnd If
```

\


---

Original Source: https://www.mindstick.com/forum/1035/use-a-string-as-object-name

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
