Solved

Replace Value

Posted on 2011-10-01
3
202 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
3 Comments
 
LVL 95

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now