Solved

Replace Value

Posted on 2011-10-01
3
199 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
Comment Utility
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
Comment Utility
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
Comment Utility
Awesome
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

744 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

18 Experts available now in Live!

Get 1:1 Help Now