Solved

Replace Value

Posted on 2011-10-01
3
206 Views
Last Modified: 2012-05-12
Hi,

Is there a way to replace the 1 or 2 in TextBox1.value like the below in VBA code.
I tried to do it like the below code but it did not work.


While i < 15
 
myObject = TextBox + i.Value

Thank you
0
Comment
Question by:samprg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 96

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 100 total points
ID: 36897063
Convert the variable to a string and then use the replace command.

If you post more of your code, I can try to help you in greater detail. (the code you posted doesn't look right to me in general, but ASSUMING it is, you would:

MyObject = Replace(Replace(TextBox, "1", ""), "2", "") + i.Value

(Seeing more of your code would be VERY helpful - this REALLY doesn't look right, but "replace" almost certainly what you're looking for).
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 400 total points
ID: 36897080
Try as below the 1 to 15 assumes the range of textboxes you are working with is 1 to 15.

The assignment to intTB could be anything ... it simply demonstrates myobkject matches onto each textbox in turn

Chris
Dim intTB As Integer
Dim myobject As Object

    For intTB = 1 To 15
        Set myobject = Me.Controls("textbox" & intTB)
        myobject.Value = intTB
    Next

Open in new window

0
 

Author Closing Comment

by:samprg
ID: 36897388
Awesome
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question