parts of a textbox

tubar

Registered User.
Local time
Today, 07:09
Joined
Jul 13, 2006
Messages
190
is it possible to write vba that would only take a part of a text box and copy the value to another text box. if text box 1 displayed "J:\TEMPLATES\Strong Reveal.jpg" text box 2 would display "J:\TEMPLATES"
 
Hi tubar

Yes, just use the Left() function. If you know how many characters you want it would just be something like =Left(TextBox1,15). If the number of characters is dependent on the location of a certain character (eg the second \) you would need to first use the Instr() function to identify the position. All thats then left is choosing an event to run your code.
 
Left(TextBox1, InstrRev(TextBox1, "\")-1)
 
Left(TextBox1, InstrRev(TextBox1, "\")-1)

Just be careful arnelgp, that would return J: from tubar's example. You would need to find the second \. If you knew the path would always be relative you could do Left(TextBox1, InstrRev(4,TextBox1, "\")-1)

EDIT: Ignore me... missed the reverse version of the function :banghead:
 
Last edited:

Users who are viewing this thread

Back
Top Bottom