Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Replace Value

Posted on 2011-10-01
3
Medium Priority
?
209 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 400 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 1600 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 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