Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing characters in a String 1

Status
Not open for further replies.

JaeBrett

Programmer
May 5, 2003
196
CN
How can I take an Array of TextBoxes, and replace all the occurances of "_" with 0?


Thanks.
 
Looop through the text boxes and use the Replace function similarily to this,

Code:
text1.text=replace(text1.text,"_","0")

Take Care,

zemp

"Show me someone with both feet on the ground and I will show you someone who can't put their pants on."
 
...Or, you could just get REALLY dangerous!

(Warning: this advise could - and probably WILL - completely knacker your app. Back it up first, and use this knowledge at your own risk!)

(Oh yes, and back it up first!)

How to completely break your app in six easy steps:

[red]0. Back it up![/red]

1. Close down the IDE.
2. Open "form1.frm" ...using Wordpad
Ctrl+H = Find & Replace...hmmm.....
3. Replace all instances of "TextBox_" with "TextBox0"
4. Save and close your form.
5. Open your project in VB.
6. Marvel at the amount of Compile and Run-Time Errors.

Breakdown:

The VB form file is a plain text file which the IDE interprets in two halves. The "top half" (which you saw when you opened it) contains information about your controls, positioning, etc. The "bottom half" contains all your carefully crafted code. OK, so when you did that Find&Replace you renamed the controls but also totally screwed your code! ;-) Still you did back it up, so no harm done, then.

You can try to experiment with cutting and pasting the code section out, or go through the controls one at a time. Be warned, however, that the Docs implore you NEVER to open the form files in a text editor as it could well (as we've seen) break your app completely. Did I mention backing it up, BTW?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top