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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replaceing information in an array

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
0
0
US
Okay I have an array that I want to replace the first character from the right with a blank. The code I tried didn't work and I was wondering if anyone could help me. I really don't want to store the information in a different array or element if possible.

For i = 0 to 48
For k = 1 to 4
Replace(Right(proparray(i,k), 1), " ")
Next k

Next i
 
Try this:

For i = 0 to 48
For k = 1 to 4
proparray(i, k) = left(proparray(i, k), len(proparray(i, k)) - 1)
proparray(i, k) += " "
Next k

Next i

(explaination: It stores the every character but the last one in proparray(i, k), and then adds a space onto the string)

HTH, Kevin B.
.Net Programmer [thumbsup]
 
It doesn't like the - sign. says the length must be greater than or equal to zero.
 
Probably because the string is empty. . . you just need to surround it with an if statement:

For i = 0 to 48
For k = 1 to 4
if not proparray(i, k) = "" then
proparray(i, k) = left(proparray(i, k), len(proparray(i, k)) - 1)
proparray(i, k) += " "
end if
Next k

Next i
Kevin B.
.Net Programmer [thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top